idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
29,200 | private Boolean validate ( final DragAndDropEvent event ) { final Transferable transferable = event . getTransferable ( ) ; final Component compsource = transferable . getSourceComponent ( ) ; if ( ! ( compsource instanceof AbstractTable ) ) { uiNotification . displayValidationError ( getI18n ( ) . getMessage ( getActionNotAllowedMessage ( ) ) ) ; return false ; } final TableTransferable tabletransferable = ( TableTransferable ) transferable ; final AbstractTable < ? > source = ( AbstractTable < ? > ) tabletransferable . getSourceComponent ( ) ; if ( ! validateIfSourceIsTargetTable ( source ) && ! hasTargetUpdatePermission ( ) ) { return false ; } final Set < Long > deletedEntityByTransferable = source . getSelectedEntitiesByTransferable ( tabletransferable ) ; if ( deletedEntityByTransferable . isEmpty ( ) ) { final String actionDidNotWork = getI18n ( ) . getMessage ( "message.action.did.not.work" ) ; uiNotification . displayValidationError ( actionDidNotWork ) ; return false ; } return true ; } | Validate the drop . | 251 | 5 |
29,201 | private boolean hasTargetUpdatePermission ( ) { if ( ! permChecker . hasUpdateTargetPermission ( ) ) { uiNotification . displayValidationError ( getI18n ( ) . getMessage ( "message.permission.insufficient" , SpPermission . UPDATE_TARGET ) ) ; return false ; } return true ; } | validate the update permission . | 75 | 6 |
29,202 | @ Override public void refreshContainer ( ) { final Indexed container = getContainerDataSource ( ) ; if ( hasGeneratedPropertySupport ( ) && getGeneratedPropertySupport ( ) . getRawContainer ( ) instanceof LazyQueryContainer ) { ( ( LazyQueryContainer ) getGeneratedPropertySupport ( ) . getRawContainer ( ) ) . refresh ( ) ; return ; } if ( container instanceof LazyQueryContainer ) { ( ( LazyQueryContainer ) container ) . refresh ( ) ; } } | Refresh the container . | 109 | 5 |
29,203 | protected HeaderRow resetHeaderDefaultRow ( ) { getHeader ( ) . removeRow ( getHeader ( ) . getDefaultRow ( ) ) ; final HeaderRow newHeaderRow = getHeader ( ) . appendRow ( ) ; getHeader ( ) . setDefaultRow ( newHeaderRow ) ; return newHeaderRow ; } | Resets the default row of the header . This means the current default row is removed and replaced with a newly created one . | 67 | 25 |
29,204 | public static int getCtrlOrMetaModifier ( ) { final WebBrowser webBrowser = Page . getCurrent ( ) . getWebBrowser ( ) ; if ( webBrowser . isMacOSX ( ) ) { return ShortcutAction . ModifierKey . META ; } return ShortcutAction . ModifierKey . CTRL ; } | Returns the ctrl or meta modifier depending on the platform . | 69 | 12 |
29,205 | protected void getPreviewButtonColor ( final String color ) { Page . getCurrent ( ) . getJavaScript ( ) . execute ( HawkbitCommonUtil . getPreviewButtonColorScript ( color ) ) ; } | Dynamic styles for window . | 44 | 5 |
29,206 | protected void createDynamicStyleForComponents ( final TextField tagName , final TextArea tagDesc , final String taregtTagColor ) { tagName . removeStyleName ( SPUIDefinitions . TAG_NAME ) ; tagDesc . removeStyleName ( SPUIDefinitions . TAG_DESC ) ; getTargetDynamicStyles ( taregtTagColor ) ; tagName . addStyleName ( TAG_NAME_DYNAMIC_STYLE ) ; tagDesc . addStyleName ( TAG_DESC_DYNAMIC_STYLE ) ; } | Set tag name and desc field border color based on chosen color . | 124 | 13 |
29,207 | protected void restoreComponentStyles ( ) { tagName . removeStyleName ( TAG_NAME_DYNAMIC_STYLE ) ; tagDesc . removeStyleName ( TAG_DESC_DYNAMIC_STYLE ) ; tagName . addStyleName ( SPUIDefinitions . TAG_NAME ) ; tagDesc . addStyleName ( SPUIDefinitions . TAG_DESC ) ; getPreviewButtonColor ( ColorPickerConstants . DEFAULT_COLOR ) ; } | reset the tag name and tag description component border color . | 107 | 11 |
29,208 | public CommonDialogWindow createWindow ( ) { window = new WindowBuilder ( SPUIDefinitions . CREATE_UPDATE_WINDOW ) . caption ( getWindowCaption ( ) ) . content ( this ) . cancelButtonClickListener ( event -> discard ( ) ) . layout ( mainLayout ) . i18n ( i18n ) . saveDialogCloseListener ( new SaveOnDialogCloseListener ( ) ) . buildCommonDialogWindow ( ) ; return window ; } | Creates the window to create or update a tag or type | 98 | 12 |
29,209 | private void previewButtonClicked ( ) { if ( ! tagPreviewBtnClicked ) { colorPickerLayout . setSelectedColor ( ColorPickerHelper . rgbToColorConverter ( ColorPickerConstants . DEFAULT_COLOR ) ) ; } tagPreviewBtnClicked = ! tagPreviewBtnClicked ; colorPickerLayout . setVisible ( tagPreviewBtnClicked ) ; } | Open color picker on click of preview button . Auto select the color based on target tag if already selected . | 89 | 22 |
29,210 | private static void getTargetDynamicStyles ( final String colorPickedPreview ) { Page . getCurrent ( ) . getJavaScript ( ) . execute ( HawkbitCommonUtil . changeToNewSelectedPreviewColor ( colorPickedPreview ) ) ; } | Get target style - Dynamically as per the color picked cannot be done from the static css . | 54 | 20 |
29,211 | private void slidersValueChangeListeners ( ) { colorPickerLayout . getRedSlider ( ) . addValueChangeListener ( new ValueChangeListener ( ) { private static final long serialVersionUID = 1L ; @ Override public void valueChange ( final ValueChangeEvent event ) { final double red = ( Double ) event . getProperty ( ) . getValue ( ) ; final Color newColor = new Color ( ( int ) red , colorPickerLayout . getSelectedColor ( ) . getGreen ( ) , colorPickerLayout . getSelectedColor ( ) . getBlue ( ) ) ; setColorToComponents ( newColor ) ; } } ) ; colorPickerLayout . getGreenSlider ( ) . addValueChangeListener ( new ValueChangeListener ( ) { private static final long serialVersionUID = 1L ; @ Override public void valueChange ( final ValueChangeEvent event ) { final double green = ( Double ) event . getProperty ( ) . getValue ( ) ; final Color newColor = new Color ( colorPickerLayout . getSelectedColor ( ) . getRed ( ) , ( int ) green , colorPickerLayout . getSelectedColor ( ) . getBlue ( ) ) ; setColorToComponents ( newColor ) ; } } ) ; colorPickerLayout . getBlueSlider ( ) . addValueChangeListener ( new ValueChangeListener ( ) { private static final long serialVersionUID = 1L ; @ Override public void valueChange ( final ValueChangeEvent event ) { final double blue = ( Double ) event . getProperty ( ) . getValue ( ) ; final Color newColor = new Color ( colorPickerLayout . getSelectedColor ( ) . getRed ( ) , colorPickerLayout . getSelectedColor ( ) . getGreen ( ) , ( int ) blue ) ; setColorToComponents ( newColor ) ; } } ) ; } | Value change listeners implementations of sliders . | 405 | 8 |
29,212 | @ ExceptionHandler ( AbstractServerRtException . class ) public ResponseEntity < ExceptionInfo > handleSpServerRtExceptions ( final HttpServletRequest request , final Exception ex ) { logRequest ( request , ex ) ; final ExceptionInfo response = createExceptionInfo ( ex ) ; final HttpStatus responseStatus ; if ( ex instanceof AbstractServerRtException ) { responseStatus = getStatusOrDefault ( ( ( AbstractServerRtException ) ex ) . getError ( ) ) ; } else { responseStatus = DEFAULT_RESPONSE_STATUS ; } return new ResponseEntity <> ( response , responseStatus ) ; } | method for handling exception of type AbstractServerRtException . Called by the Spring - Framework for exception handling . | 136 | 22 |
29,213 | @ ExceptionHandler ( HttpMessageNotReadableException . class ) public ResponseEntity < ExceptionInfo > handleHttpMessageNotReadableException ( final HttpServletRequest request , final Exception ex ) { logRequest ( request , ex ) ; final ExceptionInfo response = createExceptionInfo ( new MessageNotReadableException ( ) ) ; return new ResponseEntity <> ( response , HttpStatus . BAD_REQUEST ) ; } | Method for handling exception of type HttpMessageNotReadableException which is thrown in case the request body is not well formed and cannot be deserialized . Called by the Spring - Framework for exception handling . | 89 | 42 |
29,214 | @ ExceptionHandler ( ConstraintViolationException . class ) public ResponseEntity < ExceptionInfo > handleConstraintViolationException ( final HttpServletRequest request , final ConstraintViolationException ex ) { logRequest ( request , ex ) ; final ExceptionInfo response = new ExceptionInfo ( ) ; response . setMessage ( ex . getConstraintViolations ( ) . stream ( ) . map ( violation -> violation . getPropertyPath ( ) + MESSAGE_FORMATTER_SEPARATOR + violation . getMessage ( ) + "." ) . collect ( Collectors . joining ( MESSAGE_FORMATTER_SEPARATOR ) ) ) ; response . setExceptionClass ( ex . getClass ( ) . getName ( ) ) ; response . setErrorCode ( SpServerError . SP_REPO_CONSTRAINT_VIOLATION . getKey ( ) ) ; return new ResponseEntity <> ( response , HttpStatus . BAD_REQUEST ) ; } | Method for handling exception of type ConstraintViolationException which is thrown in case the request is rejected due to a constraint violation . Called by the Spring - Framework for exception handling . | 213 | 37 |
29,215 | @ ExceptionHandler ( ValidationException . class ) public ResponseEntity < ExceptionInfo > handleValidationException ( final HttpServletRequest request , final ValidationException ex ) { logRequest ( request , ex ) ; final ExceptionInfo response = new ExceptionInfo ( ) ; response . setMessage ( ex . getMessage ( ) ) ; response . setExceptionClass ( ex . getClass ( ) . getName ( ) ) ; response . setErrorCode ( SpServerError . SP_REPO_CONSTRAINT_VIOLATION . getKey ( ) ) ; return new ResponseEntity <> ( response , HttpStatus . BAD_REQUEST ) ; } | Method for handling exception of type ValidationException which is thrown in case the request is rejected due to invalid requests . Called by the Spring - Framework for exception handling . | 138 | 33 |
29,216 | protected void onBaseEntityEvent ( final BaseUIEntityEvent < T > baseEntityEvent ) { final BaseEntityEventType eventType = baseEntityEvent . getEventType ( ) ; if ( BaseEntityEventType . SELECTED_ENTITY == eventType || BaseEntityEventType . UPDATED_ENTITY == eventType || BaseEntityEventType . REMOVE_ENTITY == eventType ) { UI . getCurrent ( ) . access ( ( ) -> populateData ( baseEntityEvent . getEntity ( ) ) ) ; } else if ( BaseEntityEventType . MINIMIZED == eventType ) { UI . getCurrent ( ) . access ( ( ) -> setVisible ( true ) ) ; } else if ( BaseEntityEventType . MAXIMIZED == eventType ) { UI . getCurrent ( ) . access ( ( ) -> setVisible ( false ) ) ; } } | Default implementation to handle an entity event . | 190 | 8 |
29,217 | @ Bean public Queue dmfReceiverQueue ( ) { return new Queue ( amqpProperties . getReceiverQueue ( ) , true , false , false , amqpDeadletterProperties . getDeadLetterExchangeArgs ( amqpProperties . getDeadLetterExchange ( ) ) ) ; } | Create the DMF API receiver queue for retrieving DMF messages . | 70 | 13 |
29,218 | @ Bean public Queue authenticationReceiverQueue ( ) { return QueueBuilder . nonDurable ( amqpProperties . getAuthenticationReceiverQueue ( ) ) . autoDelete ( ) . withArguments ( getTTLMaxArgsAuthenticationQueue ( ) ) . build ( ) ; } | Create the DMF API receiver queue for authentication requests called by 3rd party artifact storages for download authorization by devices . | 63 | 25 |
29,219 | @ Bean public AmqpMessageHandlerService amqpMessageHandlerService ( final RabbitTemplate rabbitTemplate , final AmqpMessageDispatcherService amqpMessageDispatcherService , final ControllerManagement controllerManagement , final EntityFactory entityFactory ) { return new AmqpMessageHandlerService ( rabbitTemplate , amqpMessageDispatcherService , controllerManagement , entityFactory ) ; } | Create AMQP handler service bean . | 82 | 8 |
29,220 | @ Bean @ ConditionalOnMissingBean ( name = "listenerContainerFactory" ) public RabbitListenerContainerFactory < SimpleMessageListenerContainer > listenerContainerFactory ( final SimpleRabbitListenerContainerFactoryConfigurer configurer , final ErrorHandler errorHandler ) { final ConfigurableRabbitListenerContainerFactory factory = new ConfigurableRabbitListenerContainerFactory ( amqpProperties . isMissingQueuesFatal ( ) , amqpProperties . getDeclarationRetries ( ) , errorHandler ) ; configurer . configure ( factory , rabbitConnectionFactory ) ; return factory ; } | Create RabbitListenerContainerFactory bean if no listenerContainerFactory bean found | 121 | 13 |
29,221 | @ Bean @ ConditionalOnMissingBean ( AmqpControllerAuthentication . class ) public AmqpControllerAuthentication amqpControllerAuthentication ( final SystemManagement systemManagement , final ControllerManagement controllerManagement , final TenantConfigurationManagement tenantConfigurationManagement , final TenantAware tenantAware , final DdiSecurityProperties ddiSecruityProperties , final SystemSecurityContext systemSecurityContext ) { return new AmqpControllerAuthentication ( systemManagement , controllerManagement , tenantConfigurationManagement , tenantAware , ddiSecruityProperties , systemSecurityContext ) ; } | create the authentication bean for controller over amqp . | 123 | 11 |
29,222 | public void refreshView ( final Set < Class < ? > > eventContainers ) { eventContainers . stream ( ) . filter ( this :: supportNotificationEventContainer ) . forEach ( this :: refreshContainer ) ; clear ( ) ; } | Refresh the view by event container changes . | 51 | 9 |
29,223 | public TextField createSearchField ( final TextChangeListener textChangeListener ) { final TextField textField = style ( "filter-box" ) . styleName ( "text-style filter-box-hide" ) . buildTextComponent ( ) ; textField . setWidth ( 100.0F , Unit . PERCENTAGE ) ; textField . addTextChangeListener ( textChangeListener ) ; textField . setTextChangeEventMode ( TextChangeEventMode . LAZY ) ; // 1 seconds timeout. textField . setTextChangeTimeout ( 1000 ) ; return textField ; } | Create a search text field . | 123 | 6 |
29,224 | public void showForTargetFilter ( final Long tfqId ) { this . tfqId = tfqId ; final TargetFilterQuery tfq = targetFilterQueryManagement . get ( tfqId ) . orElseThrow ( ( ) -> new EntityNotFoundException ( TargetFilterQuery . class , tfqId ) ) ; final VerticalLayout verticalLayout = initView ( ) ; final DistributionSet distributionSet = tfq . getAutoAssignDistributionSet ( ) ; final ActionType actionType = tfq . getAutoAssignActionType ( ) ; setInitialControlValues ( distributionSet , actionType ) ; // build window after values are set to view elements final CommonDialogWindow window = new WindowBuilder ( SPUIDefinitions . CREATE_UPDATE_WINDOW ) . caption ( i18n . getMessage ( UIMessageIdProvider . CAPTION_SELECT_AUTO_ASSIGN_DS ) ) . content ( verticalLayout ) . layout ( verticalLayout ) . i18n ( i18n ) . saveDialogCloseListener ( this ) . buildCommonDialogWindow ( ) ; window . setId ( UIComponentIdProvider . DIST_SET_SELECT_WINDOW_ID ) ; window . setWidth ( 40.0F , Sizeable . Unit . PERCENTAGE ) ; UI . getCurrent ( ) . addWindow ( window ) ; window . setVisible ( true ) ; } | Shows a distribution set select window for the given target filter query | 297 | 13 |
29,225 | @ Override public void saveOrUpdate ( ) { if ( checkBox . getValue ( ) && dsCombo . getValue ( ) != null ) { final ActionType autoAssignActionType = ( ( ActionTypeOption ) actionTypeOptionGroupLayout . getActionTypeOptionGroup ( ) . getValue ( ) ) . getActionType ( ) ; updateTargetFilterQueryDS ( tfqId , ( Long ) dsCombo . getValue ( ) , autoAssignActionType ) ; } else if ( ! checkBox . getValue ( ) ) { updateTargetFilterQueryDS ( tfqId , null , null ) ; } } | Is called when the new value should be saved after the save button has been clicked | 136 | 16 |
29,226 | static ServerViewComponentClientCriterion [ ] createViewComponentClientCriteria ( ) { final ServerViewComponentClientCriterion [ ] criteria = new ServerViewComponentClientCriterion [ 4 ] ; // Target table acceptable components. criteria [ 0 ] = ServerViewComponentClientCriterion . createBuilder ( ) . dragSourceIdPrefix ( UIComponentIdProvider . TARGET_TABLE_ID ) . dropTargetIdPrefixes ( SPUIDefinitions . TARGET_TAG_ID_PREFIXS , UIComponentIdProvider . DIST_TABLE_ID ) . dropAreaIds ( UIComponentIdProvider . TARGET_TAG_DROP_AREA_ID , UIComponentIdProvider . DIST_TABLE_ID ) . build ( ) ; // Target Tag acceptable components. criteria [ 1 ] = ServerViewComponentClientCriterion . createBuilder ( ) . dragSourceIdPrefix ( SPUIDefinitions . TARGET_TAG_ID_PREFIXS ) . dropTargetIdPrefixes ( UIComponentIdProvider . TARGET_TABLE_ID , UIComponentIdProvider . DIST_TABLE_ID ) . dropAreaIds ( UIComponentIdProvider . TARGET_TABLE_ID , UIComponentIdProvider . DIST_TABLE_ID ) . build ( ) ; // Distribution table acceptable components. criteria [ 2 ] = ServerViewComponentClientCriterion . createBuilder ( ) . dragSourceIdPrefix ( UIComponentIdProvider . DIST_TABLE_ID ) . dropTargetIdPrefixes ( UIComponentIdProvider . TARGET_TABLE_ID , UIComponentIdProvider . TARGET_DROP_FILTER_ICON , SPUIDefinitions . DISTRIBUTION_TAG_ID_PREFIXS ) . dropAreaIds ( UIComponentIdProvider . TARGET_TABLE_ID , UIComponentIdProvider . TARGET_DROP_FILTER_ICON , UIComponentIdProvider . DISTRIBUTION_TAG_TABLE_ID ) . build ( ) ; // Distribution tag acceptable components. criteria [ 3 ] = ServerViewComponentClientCriterion . createBuilder ( ) . dragSourceIdPrefix ( SPUIDefinitions . DISTRIBUTION_TAG_ID_PREFIXS ) . dropTargetIdPrefixes ( UIComponentIdProvider . DIST_TABLE_ID ) . dropAreaIds ( UIComponentIdProvider . DIST_TABLE_ID ) . build ( ) ; return criteria ; } | Configures the elements of the composite accept criterion for the Management View . | 553 | 14 |
29,227 | public static String trimAndNullIfEmpty ( final String text ) { if ( text != null && ! text . trim ( ) . isEmpty ( ) ) { return text . trim ( ) ; } return null ; } | Trims the text and converts into null in case of an empty string . | 45 | 15 |
29,228 | public static String concatStrings ( final String delimiter , final String ... texts ) { final String delim = delimiter == null ? "" : delimiter ; final StringBuilder conCatStrBldr = new StringBuilder ( ) ; if ( null != texts ) { for ( final String text : texts ) { conCatStrBldr . append ( delim ) ; conCatStrBldr . append ( text ) ; } } final String conCatedStr = conCatStrBldr . toString ( ) ; return delim . length ( ) > 0 && conCatedStr . startsWith ( delim ) ? conCatedStr . substring ( 1 ) : conCatedStr ; } | Concatenate the given text all the string arguments with the given delimiter . | 147 | 17 |
29,229 | public static String getSoftwareModuleName ( final String caption , final String name ) { return new StringBuilder ( ) . append ( DIV_DESCRIPTION_START + caption + " : " + getBoldHTMLText ( getFormattedName ( name ) ) ) . append ( DIV_DESCRIPTION_END ) . toString ( ) ; } | Get Label for Artifact Details . | 74 | 6 |
29,230 | public static String getPollStatusToolTip ( final PollStatus pollStatus , final VaadinMessageSource i18N ) { if ( pollStatus != null && pollStatus . getLastPollDate ( ) != null && pollStatus . isOverdue ( ) ) { final TimeZone tz = SPDateTimeUtil . getBrowserTimeZone ( ) ; return i18N . getMessage ( UIMessageIdProvider . TOOLTIP_OVERDUE , SPDateTimeUtil . getDurationFormattedString ( pollStatus . getOverdueDate ( ) . atZone ( SPDateTimeUtil . getTimeZoneId ( tz ) ) . toInstant ( ) . toEpochMilli ( ) , pollStatus . getCurrentDate ( ) . atZone ( SPDateTimeUtil . getTimeZoneId ( tz ) ) . toInstant ( ) . toEpochMilli ( ) , i18N ) ) ; } return null ; } | Get tool tip for Poll status . | 202 | 7 |
29,231 | public static String getFormattedName ( final String orgText ) { return trimAndNullIfEmpty ( orgText ) == null ? SPUIDefinitions . SPACE : orgText ; } | Null check for text . | 39 | 5 |
29,232 | public static float getArtifactUploadPopupWidth ( final float newBrowserWidth , final int minPopupWidth ) { final float extraWidth = findRequiredSwModuleExtraWidth ( newBrowserWidth ) ; if ( extraWidth + minPopupWidth > SPUIDefinitions . MAX_UPLOAD_CONFIRMATION_POPUP_WIDTH ) { return SPUIDefinitions . MAX_UPLOAD_CONFIRMATION_POPUP_WIDTH ; } return extraWidth + minPopupWidth ; } | Get artifact upload pop up width . | 115 | 7 |
29,233 | public static String removePrefix ( final String text , final String prefix ) { if ( text != null ) { return text . replaceFirst ( prefix , "" ) ; } return null ; } | Remove the prefix from text . | 39 | 6 |
29,234 | public static Label getFormatedLabel ( final String labelContent ) { final Label labelValue = new Label ( labelContent , ContentMode . HTML ) ; labelValue . setSizeFull ( ) ; labelValue . addStyleName ( SPUIDefinitions . TEXT_STYLE ) ; labelValue . addStyleName ( "label-style" ) ; return labelValue ; } | Get formatted label . Appends ellipses if content does not fit the label . | 79 | 17 |
29,235 | public static String createAssignmentMessage ( final String tagName , final AssignmentResult < ? extends NamedEntity > result , final VaadinMessageSource i18n ) { final StringBuilder formMsg = new StringBuilder ( ) ; final int assignedCount = result . getAssigned ( ) ; final int alreadyAssignedCount = result . getAlreadyAssigned ( ) ; final int unassignedCount = result . getUnassigned ( ) ; if ( assignedCount == 1 ) { formMsg . append ( i18n . getMessage ( "message.target.assigned.one" , result . getAssignedEntity ( ) . get ( 0 ) . getName ( ) , tagName ) ) . append ( "<br>" ) ; } else if ( assignedCount > 1 ) { formMsg . append ( i18n . getMessage ( "message.target.assigned.many" , assignedCount , tagName ) ) . append ( "<br>" ) ; if ( alreadyAssignedCount > 0 ) { final String alreadyAssigned = i18n . getMessage ( "message.target.alreadyAssigned" , alreadyAssignedCount ) ; formMsg . append ( alreadyAssigned ) . append ( "<br>" ) ; } } if ( unassignedCount == 1 ) { formMsg . append ( i18n . getMessage ( "message.target.unassigned.one" , result . getUnassignedEntity ( ) . get ( 0 ) . getName ( ) , tagName ) ) . append ( "<br>" ) ; } else if ( unassignedCount > 1 ) { formMsg . append ( i18n . getMessage ( "message.target.unassigned.many" , unassignedCount , tagName ) ) . append ( "<br>" ) ; } return formMsg . toString ( ) ; } | Display Target Tag action message . | 390 | 6 |
29,236 | public static LazyQueryContainer createLazyQueryContainer ( final BeanQueryFactory < ? extends AbstractBeanQuery < ? > > queryFactory ) { queryFactory . setQueryConfiguration ( Collections . emptyMap ( ) ) ; return new LazyQueryContainer ( new LazyQueryDefinition ( true , 20 , SPUILabelDefinitions . VAR_NAME ) , queryFactory ) ; } | Create a lazy query container for the given query bean factory with empty configurations . | 81 | 15 |
29,237 | public static LazyQueryContainer createDSLazyQueryContainer ( final BeanQueryFactory < ? extends AbstractBeanQuery < ? > > queryFactory ) { queryFactory . setQueryConfiguration ( Collections . emptyMap ( ) ) ; return new LazyQueryContainer ( new LazyQueryDefinition ( true , 20 , "tagIdName" ) , queryFactory ) ; } | Create lazy query container for DS type . | 76 | 8 |
29,238 | public static void getDsTableColumnProperties ( final Container container ) { final LazyQueryContainer lqc = ( LazyQueryContainer ) container ; lqc . addContainerProperty ( SPUILabelDefinitions . VAR_ID , Long . class , null , false , false ) ; lqc . addContainerProperty ( SPUILabelDefinitions . VAR_DESC , String . class , "" , false , true ) ; lqc . addContainerProperty ( SPUILabelDefinitions . VAR_VERSION , String . class , null , false , false ) ; lqc . addContainerProperty ( SPUILabelDefinitions . VAR_NAME , String . class , null , false , true ) ; lqc . addContainerProperty ( SPUILabelDefinitions . VAR_CREATED_BY , String . class , null , false , true ) ; lqc . addContainerProperty ( SPUILabelDefinitions . VAR_LAST_MODIFIED_BY , String . class , null , false , true ) ; lqc . addContainerProperty ( SPUILabelDefinitions . VAR_CREATED_DATE , String . class , null , false , true ) ; lqc . addContainerProperty ( SPUILabelDefinitions . VAR_LAST_MODIFIED_DATE , String . class , null , false , true ) ; } | Set distribution table column properties . | 302 | 6 |
29,239 | public static String getScriptSMHighlightWithColor ( final String colorCSS ) { return new StringBuilder ( ) . append ( SM_HIGHLIGHT_SCRIPT_CURRENT ) . append ( "smHighlightStyle = smHighlightStyle + \"" ) . append ( colorCSS ) . append ( "\";" ) . append ( SM_HIGHLIGHT_SCRIPT_APPEND ) . toString ( ) ; } | Highlight software module rows with the color of sw - type . | 92 | 13 |
29,240 | public static String changeToNewSelectedPreviewColor ( final String colorPickedPreview ) { return new StringBuilder ( ) . append ( NEW_PREVIEW_COLOR_REMOVE_SCRIPT ) . append ( NEW_PREVIEW_COLOR_CREATE_SCRIPT ) . append ( "var newColorPreviewStyle = \".v-app .new-tag-name{ border: solid 3px " ) . append ( colorPickedPreview ) . append ( " !important; width:138px; margin-left:2px !important; box-shadow:none !important; } \"; " ) . append ( "newColorPreviewStyle = newColorPreviewStyle + \".v-app .new-tag-desc{ border: solid 3px " ) . append ( colorPickedPreview ) . append ( " !important; width:138px; height:75px !important; margin-top:4px !important; margin-left:2px !important;;box-shadow:none !important;} \"; " ) . append ( NEW_PREVIEW_COLOR_SET_STYLE_SCRIPT ) . toString ( ) ; } | Get javascript to reflect new color selection in color picker preview for name and description fields . | 245 | 18 |
29,241 | public static String getPreviewButtonColorScript ( final String color ) { return new StringBuilder ( ) . append ( PREVIEW_BUTTON_COLOR_REMOVE_SCRIPT ) . append ( PREVIEW_BUTTON_COLOR_CREATE_SCRIPT ) . append ( "var tagColorPreviewStyle = \".v-app .tag-color-preview{ height: 15px !important; padding: 0 10px !important; border: 0px !important; margin-left:12px !important; margin-top: 4px !important; border-width: 0 !important; background: " ) . append ( color ) . append ( " } .v-app .tag-color-preview:after{ border-color: none !important; box-shadow:none !important;} \"; " ) . append ( PREVIEW_BUTTON_COLOR_SET_STYLE_SCRIPT ) . toString ( ) ; } | Get javascript to reflect new color selection for preview button . | 201 | 11 |
29,242 | public static void applyStatusLblStyle ( final Table targetTable , final Button pinBtn , final Object itemId ) { final Item item = targetTable . getItem ( itemId ) ; if ( item != null ) { final TargetUpdateStatus updateStatus = ( TargetUpdateStatus ) item . getItemProperty ( SPUILabelDefinitions . VAR_TARGET_STATUS ) . getValue ( ) ; pinBtn . removeStyleName ( "statusIconRed statusIconBlue statusIconGreen statusIconYellow statusIconLightBlue" ) ; if ( updateStatus == TargetUpdateStatus . ERROR ) { pinBtn . addStyleName ( SPUIStyleDefinitions . STATUS_ICON_RED ) ; } else if ( updateStatus == TargetUpdateStatus . UNKNOWN ) { pinBtn . addStyleName ( SPUIStyleDefinitions . STATUS_ICON_BLUE ) ; } else if ( updateStatus == TargetUpdateStatus . IN_SYNC ) { pinBtn . addStyleName ( SPUIStyleDefinitions . STATUS_ICON_GREEN ) ; } else if ( updateStatus == TargetUpdateStatus . PENDING ) { pinBtn . addStyleName ( SPUIStyleDefinitions . STATUS_ICON_YELLOW ) ; } else if ( updateStatus == TargetUpdateStatus . REGISTERED ) { pinBtn . addStyleName ( SPUIStyleDefinitions . STATUS_ICON_LIGHT_BLUE ) ; } } } | Apply style for status label in target table . | 326 | 9 |
29,243 | public static String formattingFinishedPercentage ( final RolloutGroup rolloutGroup , final float finishedPercentage ) { float tmpFinishedPercentage = 0 ; switch ( rolloutGroup . getStatus ( ) ) { case READY : case SCHEDULED : case ERROR : tmpFinishedPercentage = 0.0F ; break ; case FINISHED : tmpFinishedPercentage = 100.0F ; break ; case RUNNING : tmpFinishedPercentage = finishedPercentage ; break ; default : break ; } return String . format ( "%.1f" , tmpFinishedPercentage ) ; } | Formats the finished percentage of a rollout group into a string with one digit after comma . | 127 | 18 |
29,244 | public static String getStatusLabelDetailsInString ( final String value , final String style , final String id ) { final StringBuilder val = new StringBuilder ( ) ; if ( ! StringUtils . isEmpty ( value ) ) { val . append ( "value:" ) . append ( value ) . append ( "," ) ; } if ( ! StringUtils . isEmpty ( style ) ) { val . append ( "style:" ) . append ( style ) . append ( "," ) ; } return val . append ( "id:" ) . append ( id ) . toString ( ) ; } | Returns a formatted string as needed by label custom render . This string holds the properties of a status label . | 125 | 21 |
29,245 | public static String getCodePoint ( final StatusFontIcon statusFontIcon ) { if ( statusFontIcon == null ) { return null ; } return statusFontIcon . getFontIcon ( ) != null ? Integer . toString ( statusFontIcon . getFontIcon ( ) . getCodepoint ( ) ) : null ; } | Receive the code point of a given StatusFontIcon . | 68 | 12 |
29,246 | public static Locale getCurrentLocale ( ) { final UI currentUI = UI . getCurrent ( ) ; return currentUI == null ? Locale . getDefault ( ) : currentUI . getLocale ( ) ; } | Gets the locale of the current Vaadin UI . If the locale can not be determined the default locale is returned instead . | 47 | 25 |
29,247 | public static String getArtifactoryDetailsLabelId ( final String name , final VaadinMessageSource i18n ) { String caption ; if ( StringUtils . hasText ( name ) ) { caption = i18n . getMessage ( UIMessageIdProvider . CAPTION_ARTIFACT_DETAILS_OF , HawkbitCommonUtil . getBoldHTMLText ( name ) ) ; } else { caption = i18n . getMessage ( UIMessageIdProvider . CAPTION_ARTIFACT_DETAILS ) ; } return getCaptionText ( caption ) ; } | Creates the caption of the Artifact Details table | 126 | 9 |
29,248 | public static Locale getLocaleToBeUsed ( final UiProperties . Localization localizationProperties , final Locale desiredLocale ) { final List < String > availableLocals = localizationProperties . getAvailableLocals ( ) ; // ckeck if language code of UI locale matches an available local. // Country, region and variant are ignored. "availableLocals" must only // contain language codes without country or other extensions. if ( availableLocals . contains ( desiredLocale . getLanguage ( ) ) ) { return desiredLocale ; } return new Locale ( localizationProperties . getDefaultLocal ( ) ) ; } | Determine the language that should be used considering localization properties and a desired Locale | 134 | 17 |
29,249 | public static void initLocalization ( final UI ui , final Localization localizationProperties , final VaadinMessageSource i18n ) { ui . setLocale ( HawkbitCommonUtil . getLocaleToBeUsed ( localizationProperties , ui . getSession ( ) . getLocale ( ) ) ) ; ui . getReconnectDialogConfiguration ( ) . setDialogText ( i18n . getMessage ( UIMessageIdProvider . VAADIN_SYSTEM_TRYINGRECONNECT ) ) ; } | Set localization considering properties and UI settings . | 114 | 8 |
29,250 | public void populateDSMetadata ( final DistributionSet distributionSet ) { removeAllItems ( ) ; if ( null == distributionSet ) { return ; } selectedDistSetId = distributionSet . getId ( ) ; final List < DistributionSetMetadata > dsMetadataList = distributionSetManagement . findMetaDataByDistributionSetId ( PageRequest . of ( 0 , MAX_METADATA_QUERY ) , selectedDistSetId ) . getContent ( ) ; if ( null != dsMetadataList && ! dsMetadataList . isEmpty ( ) ) { dsMetadataList . forEach ( this :: setMetadataProperties ) ; } } | Populate distribution set metadata . | 142 | 6 |
29,251 | public void addSoftwareModule ( final DmfSoftwareModule createSoftwareModule ) { if ( softwareModules == null ) { softwareModules = new ArrayList <> ( ) ; } softwareModules . add ( createSoftwareModule ) ; } | Add a Software module . | 51 | 5 |
29,252 | static < T > void validateTenantConfigurationDataType ( final TenantConfigurationKey configurationKey , final Class < T > propertyType ) { if ( ! configurationKey . getDataType ( ) . isAssignableFrom ( propertyType ) ) { throw new TenantConfigurationValidatorException ( String . format ( "Cannot parse the database value of type %s into the type %s." , configurationKey . getDataType ( ) , propertyType ) ) ; } } | Validates the data type of the tenant configuration . If it is possible to cast to the given data type . | 99 | 22 |
29,253 | public Label buildLabel ( ) { final Label label = createLabel ( ) ; label . setImmediate ( false ) ; label . setWidth ( "-1px" ) ; label . setHeight ( "-1px" ) ; if ( StringUtils . hasText ( caption ) ) { label . setCaption ( caption ) ; } return label ; } | Build label . | 74 | 3 |
29,254 | @ SuppressWarnings ( "unchecked" ) public void updateTarget ( final Target updatedTarget ) { if ( updatedTarget != null ) { final Item item = getItem ( updatedTarget . getId ( ) ) ; // TO DO update SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER // & // SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER /* * Update the status which will trigger the value change lister * registered for the target update status. That listener will * update the new status icon showing for this target in the table. */ item . getItemProperty ( SPUILabelDefinitions . VAR_TARGET_STATUS ) . setValue ( updatedTarget . getUpdateStatus ( ) ) ; /* * Update the last query which will trigger the value change lister * registered for the target last query column. That listener will * update the latest query date for this target in the tooltip. */ item . getItemProperty ( SPUILabelDefinitions . LAST_QUERY_DATE ) . setValue ( updatedTarget . getLastTargetQuery ( ) ) ; item . getItemProperty ( SPUILabelDefinitions . VAR_LAST_MODIFIED_BY ) . setValue ( UserDetailsFormatter . loadAndFormatLastModifiedBy ( updatedTarget ) ) ; item . getItemProperty ( SPUILabelDefinitions . VAR_LAST_MODIFIED_DATE ) . setValue ( SPDateTimeUtil . getFormattedDate ( updatedTarget . getLastModifiedAt ( ) ) ) ; item . getItemProperty ( SPUILabelDefinitions . VAR_DESC ) . setValue ( updatedTarget . getDescription ( ) ) ; /* Update the new Name, Description and poll date */ item . getItemProperty ( SPUILabelDefinitions . VAR_NAME ) . setValue ( updatedTarget . getName ( ) ) ; } } | To update target details in the table . | 418 | 8 |
29,255 | private void resetTargetCountDetails ( ) { final long totalTargetsCount = getTotalTargetsCount ( ) ; managementUIState . setTargetsCountAll ( totalTargetsCount ) ; final boolean noTagClicked = managementUIState . getTargetTableFilters ( ) . isNoTagSelected ( ) ; final Long distributionId = managementUIState . getTargetTableFilters ( ) . getDistributionSet ( ) . map ( DistributionSetIdName :: getId ) . orElse ( null ) ; final Long pinnedDistId = managementUIState . getTargetTableFilters ( ) . getPinnedDistId ( ) . orElse ( null ) ; final String searchText = managementUIState . getTargetTableFilters ( ) . getSearchText ( ) . map ( text -> { if ( StringUtils . isEmpty ( text ) ) { return null ; } return String . format ( "%%%s%%" , text ) ; } ) . orElse ( null ) ; String [ ] targetTags = null ; if ( isFilteredByTags ( ) ) { targetTags = managementUIState . getTargetTableFilters ( ) . getClickedTargetTags ( ) . toArray ( new String [ 0 ] ) ; } Collection < TargetUpdateStatus > status = null ; if ( isFilteredByStatus ( ) ) { status = managementUIState . getTargetTableFilters ( ) . getClickedStatusTargetTags ( ) ; } Boolean overdueState = null ; if ( managementUIState . getTargetTableFilters ( ) . isOverdueFilterEnabled ( ) ) { overdueState = managementUIState . getTargetTableFilters ( ) . isOverdueFilterEnabled ( ) ; } final long size = getTargetsCountWithFilter ( totalTargetsCount , pinnedDistId , new FilterParams ( status , overdueState , searchText , distributionId , noTagClicked , targetTags ) ) ; if ( size > SPUIDefinitions . MAX_TABLE_ENTRIES ) { managementUIState . setTargetsTruncated ( size - SPUIDefinitions . MAX_TABLE_ENTRIES ) ; } } | Set total target count and count of targets truncated in target table . | 462 | 14 |
29,256 | static ServerViewComponentClientCriterion [ ] createViewComponentClientCriteria ( ) { final ServerViewComponentClientCriterion [ ] criteria = new ServerViewComponentClientCriterion [ 1 ] ; // Upload software module table acceptable components. criteria [ 0 ] = ServerViewComponentClientCriterion . createBuilder ( ) . dragSourceIdPrefix ( UIComponentIdProvider . UPLOAD_SOFTWARE_MODULE_TABLE ) . dropTargetIdPrefixes ( UIComponentIdProvider . DIST_TABLE_ID ) . dropAreaIds ( UIComponentIdProvider . DIST_TABLE_ID ) . build ( ) ; return criteria ; } | Configures the elements of the composite accept criterion for the Distributions View . | 141 | 15 |
29,257 | @ EventBusListenerMethod ( scope = EventScope . UI ) void onEvent ( final RolloutEvent event ) { switch ( event ) { case FILTER_BY_TEXT : case CREATE_ROLLOUT : case UPDATE_ROLLOUT : case SHOW_ROLLOUTS : refreshContainer ( ) ; break ; default : break ; } } | Handles the RolloutEvent to refresh Grid . | 73 | 10 |
29,258 | @ EventBusListenerMethod ( scope = EventScope . UI ) public void onRolloutChangeEvent ( final RolloutChangeEventContainer eventContainer ) { eventContainer . getEvents ( ) . forEach ( this :: handleEvent ) ; } | Handles the RolloutChangeEvent to refresh the item in the grid . | 49 | 15 |
29,259 | public void populateMetadata ( final Target target ) { removeAllItems ( ) ; if ( target == null ) { return ; } selectedTargetId = target . getId ( ) ; final List < TargetMetadata > targetMetadataList = targetManagement . findMetaDataByControllerId ( PageRequest . of ( 0 , MAX_METADATA_QUERY ) , target . getControllerId ( ) ) . getContent ( ) ; if ( targetMetadataList != null && ! targetMetadataList . isEmpty ( ) ) { targetMetadataList . forEach ( this :: setMetadataProperties ) ; } } | Populate target metadata . | 131 | 5 |
29,260 | private boolean scheduleRolloutGroup ( final JpaRollout rollout , final JpaRolloutGroup group ) { final long targetsInGroup = rolloutTargetGroupRepository . countByRolloutGroup ( group ) ; final long countOfActions = actionRepository . countByRolloutAndRolloutGroup ( rollout , group ) ; long actionsLeft = targetsInGroup - countOfActions ; if ( actionsLeft > 0 ) { actionsLeft -= createActionsForRolloutGroup ( rollout , group ) ; } if ( actionsLeft <= 0 ) { group . setStatus ( RolloutGroupStatus . SCHEDULED ) ; rolloutGroupRepository . save ( group ) ; return true ; } return false ; } | Schedules a group of the rollout . Scheduled Actions are created to achieve this . The creation of those Actions is allowed to fail . | 149 | 28 |
29,261 | private void createScheduledAction ( final Collection < Target > targets , final DistributionSet distributionSet , final ActionType actionType , final Long forcedTime , final Rollout rollout , final RolloutGroup rolloutGroup ) { // cancel all current scheduled actions for this target. E.g. an action // is already scheduled and a next action is created then cancel the // current scheduled action to cancel. E.g. a new scheduled action is // created. final List < Long > targetIds = targets . stream ( ) . map ( Target :: getId ) . collect ( Collectors . toList ( ) ) ; deploymentManagement . cancelInactiveScheduledActionsForTargets ( targetIds ) ; targets . forEach ( target -> { assertActionsPerTargetQuota ( target , 1 ) ; final JpaAction action = new JpaAction ( ) ; action . setTarget ( target ) ; action . setActive ( false ) ; action . setDistributionSet ( distributionSet ) ; action . setActionType ( actionType ) ; action . setForcedTime ( forcedTime ) ; action . setStatus ( Status . SCHEDULED ) ; action . setRollout ( rollout ) ; action . setRolloutGroup ( rolloutGroup ) ; actionRepository . save ( action ) ; } ) ; } | Creates an action entry into the action repository . In case of existing scheduled actions the scheduled actions gets canceled . A scheduled action is created in - active . | 276 | 31 |
29,262 | public static ResponseEntity < Void > writeMD5FileResponse ( final HttpServletResponse response , final String md5Hash , final String filename ) throws IOException { if ( md5Hash == null ) { return ResponseEntity . notFound ( ) . build ( ) ; } final StringBuilder builder = new StringBuilder ( ) ; builder . append ( md5Hash ) ; builder . append ( " " ) ; builder . append ( filename ) ; final byte [ ] content = builder . toString ( ) . getBytes ( StandardCharsets . US_ASCII ) ; final StringBuilder header = new StringBuilder ( ) . append ( "attachment;filename=" ) . append ( filename ) . append ( ARTIFACT_MD5_DWNL_SUFFIX ) ; response . setContentLength ( content . length ) ; response . setHeader ( HttpHeaders . CONTENT_DISPOSITION , header . toString ( ) ) ; response . getOutputStream ( ) . write ( content ) ; return ResponseEntity . ok ( ) . build ( ) ; } | Write a md5 file response . | 226 | 7 |
29,263 | @ Override public String getItemCaption ( final Object itemId ) { if ( itemId != null && itemId . equals ( getValue ( ) ) && ! StringUtils . isEmpty ( selectedValueCaption ) ) { return selectedValueCaption ; } return super . getItemCaption ( itemId ) ; } | Overriden in order to return the caption for the selected distribution set from cache . Otherwise it could lead to multiple database queries trying to retrieve the caption from container when it is not present in filtered options . | 69 | 41 |
29,264 | public int setInitialValueFilter ( final String initialFilterString ) { final Filter filter = buildFilter ( initialFilterString , getFilteringMode ( ) ) ; if ( filter != null ) { final LazyQueryContainer container = ( LazyQueryContainer ) getContainerDataSource ( ) ; try { container . addContainerFilter ( filter ) ; return container . size ( ) ; } finally { container . removeContainerFilter ( filter ) ; } } return 0 ; } | Before setting the value of the selected distribution set we need to initialize the container and apply the right filter in order to limit the number of entities and save them in container cache . Otherwise combobox will try to find the corresponding id from container leading to multiple database queries . | 96 | 54 |
29,265 | private void addContainerproperties ( ) { /* Create HierarchicalContainer container */ container . addContainerProperty ( SPUILabelDefinitions . NAME , String . class , null ) ; container . addContainerProperty ( SPUILabelDefinitions . VAR_CREATED_BY , String . class , null ) ; container . addContainerProperty ( SPUILabelDefinitions . VAR_CREATED_DATE , Date . class , null ) ; container . addContainerProperty ( SPUILabelDefinitions . VAR_LAST_MODIFIED_BY , String . class , null , false , true ) ; container . addContainerProperty ( SPUILabelDefinitions . VAR_LAST_MODIFIED_DATE , String . class , null , false , true ) ; container . addContainerProperty ( SPUILabelDefinitions . VAR_TARGET_STATUS , TargetUpdateStatus . class , null ) ; container . addContainerProperty ( SPUILabelDefinitions . VAR_DESC , String . class , "" , false , true ) ; container . addContainerProperty ( ASSIGN_DIST_SET , DistributionSet . class , null , false , true ) ; container . addContainerProperty ( INSTALL_DIST_SET , DistributionSet . class , null , false , true ) ; container . addContainerProperty ( SPUILabelDefinitions . ASSIGNED_DISTRIBUTION_NAME_VER , String . class , "" ) ; container . addContainerProperty ( SPUILabelDefinitions . INSTALLED_DISTRIBUTION_NAME_VER , String . class , null ) ; } | Create a empty HierarchicalContainer . | 346 | 8 |
29,266 | static JpaRolloutGroup prepareRolloutGroupWithDefaultConditions ( final RolloutGroupCreate create , final RolloutGroupConditions conditions ) { final JpaRolloutGroup group = ( ( JpaRolloutGroupCreate ) create ) . build ( ) ; if ( group . getSuccessCondition ( ) == null ) { group . setSuccessCondition ( conditions . getSuccessCondition ( ) ) ; } if ( group . getSuccessConditionExp ( ) == null ) { group . setSuccessConditionExp ( conditions . getSuccessConditionExp ( ) ) ; } if ( group . getSuccessAction ( ) == null ) { group . setSuccessAction ( conditions . getSuccessAction ( ) ) ; } if ( group . getSuccessActionExp ( ) == null ) { group . setSuccessActionExp ( conditions . getSuccessActionExp ( ) ) ; } if ( group . getErrorCondition ( ) == null ) { group . setErrorCondition ( conditions . getErrorCondition ( ) ) ; } if ( group . getErrorConditionExp ( ) == null ) { group . setErrorConditionExp ( conditions . getErrorConditionExp ( ) ) ; } if ( group . getErrorAction ( ) == null ) { group . setErrorAction ( conditions . getErrorAction ( ) ) ; } if ( group . getErrorActionExp ( ) == null ) { group . setErrorActionExp ( conditions . getErrorActionExp ( ) ) ; } return group ; } | In case the given group is missing conditions or actions they will be set from the supplied default conditions . | 303 | 20 |
29,267 | @ RabbitListener ( queues = "${hawkbit.dmf.rabbitmq.receiverQueue:dmf_receiver}" , containerFactory = "listenerContainerFactory" ) public Message onMessage ( final Message message , @ Header ( name = MessageHeaderKey . TYPE , required = false ) final String type , @ Header ( name = MessageHeaderKey . TENANT , required = false ) final String tenant ) { return onMessage ( message , type , tenant , getRabbitTemplate ( ) . getConnectionFactory ( ) . getVirtualHost ( ) ) ; } | Method to handle all incoming DMF amqp messages . | 121 | 12 |
29,268 | private void registerTarget ( final Message message , final String virtualHost ) { final String thingId = getStringHeaderKey ( message , MessageHeaderKey . THING_ID , "ThingId is null" ) ; final String replyTo = message . getMessageProperties ( ) . getReplyTo ( ) ; if ( StringUtils . isEmpty ( replyTo ) ) { logAndThrowMessageError ( message , "No ReplyTo was set for the createThing message." ) ; } final URI amqpUri = IpUtil . createAmqpUri ( virtualHost , replyTo ) ; final Target target = controllerManagement . findOrRegisterTargetIfItDoesNotExist ( thingId , amqpUri ) ; LOG . debug ( "Target {} reported online state." , thingId ) ; lookIfUpdateAvailable ( target ) ; } | Method to create a new target or to find the target if it already exists . | 183 | 16 |
29,269 | private void handleIncomingEvent ( final Message message ) { switch ( EventTopic . valueOf ( getStringHeaderKey ( message , MessageHeaderKey . TOPIC , "EventTopic is null" ) ) ) { case UPDATE_ACTION_STATUS : updateActionStatus ( message ) ; break ; case UPDATE_ATTRIBUTES : updateAttributes ( message ) ; break ; default : logAndThrowMessageError ( message , "Got event without appropriate topic." ) ; break ; } } | Method to handle the different topics to an event . | 101 | 10 |
29,270 | private void updateActionStatus ( final Message message ) { final DmfActionUpdateStatus actionUpdateStatus = convertMessage ( message , DmfActionUpdateStatus . class ) ; final Action action = checkActionExist ( message , actionUpdateStatus ) ; final List < String > messages = actionUpdateStatus . getMessage ( ) ; if ( isCorrelationIdNotEmpty ( message ) ) { messages . add ( RepositoryConstants . SERVER_MESSAGE_PREFIX + "DMF message correlation-id " + message . getMessageProperties ( ) . getCorrelationId ( ) ) ; } final Status status = mapStatus ( message , actionUpdateStatus , action ) ; final ActionStatusCreate actionStatus = entityFactory . actionStatus ( ) . create ( action . getId ( ) ) . status ( status ) . messages ( messages ) ; final Action addUpdateActionStatus = getUpdateActionStatus ( status , actionStatus ) ; if ( ! addUpdateActionStatus . isActive ( ) || ( addUpdateActionStatus . hasMaintenanceSchedule ( ) && addUpdateActionStatus . isMaintenanceWindowAvailable ( ) ) ) { lookIfUpdateAvailable ( action . getTarget ( ) ) ; } } | Method to update the action status of an action through the event . | 256 | 13 |
29,271 | @ SuppressWarnings ( "squid:S3655" ) private Action checkActionExist ( final Message message , final DmfActionUpdateStatus actionUpdateStatus ) { final Long actionId = actionUpdateStatus . getActionId ( ) ; LOG . debug ( "Target notifies intermediate about action {} with status {}." , actionId , actionUpdateStatus . getActionStatus ( ) ) ; final Optional < Action > findActionWithDetails = controllerManagement . findActionWithDetails ( actionId ) ; if ( ! findActionWithDetails . isPresent ( ) ) { logAndThrowMessageError ( message , "Got intermediate notification about action " + actionId + " but action does not exist" ) ; } return findActionWithDetails . get ( ) ; } | get will not be called | 161 | 5 |
29,272 | public boolean matchRemoteEvent ( final TenantAwareEvent tenantAwareEvent ) { if ( ! ( tenantAwareEvent instanceof RemoteIdEvent ) || entityClass == null || entityIds == null ) { return false ; } final RemoteIdEvent remoteIdEvent = ( RemoteIdEvent ) tenantAwareEvent ; try { final Class < ? > remoteEntityClass = Class . forName ( remoteIdEvent . getEntityClass ( ) ) ; return entityClass . isAssignableFrom ( remoteEntityClass ) && entityIds . contains ( remoteIdEvent . getEntityId ( ) ) ; } catch ( final ClassNotFoundException e ) { LOG . error ( "Entity Class of remoteIdEvent cannot be found" , e ) ; return false ; } } | Checks if the remote event is the same as this UI event . Then maybe you can skip the remote event because it is already executed . | 161 | 28 |
29,273 | @ PostConstruct public void init ( ) { if ( defaultDistributionSetTypeLayout . getComponentCount ( ) > 0 ) { configurationViews . add ( defaultDistributionSetTypeLayout ) ; } configurationViews . add ( repositoryConfigurationView ) ; configurationViews . add ( rolloutConfigurationView ) ; configurationViews . add ( authenticationConfigurationView ) ; configurationViews . add ( pollingConfigurationView ) ; if ( customConfigurationViews != null ) { configurationViews . addAll ( customConfigurationViews . stream ( ) . filter ( ConfigurationGroup :: show ) . collect ( Collectors . toList ( ) ) ) ; } final Panel rootPanel = new Panel ( ) ; rootPanel . setStyleName ( "tenantconfig-root" ) ; final VerticalLayout rootLayout = new VerticalLayout ( ) ; rootLayout . setSizeFull ( ) ; rootLayout . setMargin ( true ) ; rootLayout . setSpacing ( true ) ; configurationViews . forEach ( rootLayout :: addComponent ) ; final HorizontalLayout buttonContent = saveConfigurationButtonsLayout ( ) ; rootLayout . addComponent ( buttonContent ) ; rootLayout . setComponentAlignment ( buttonContent , Alignment . BOTTOM_LEFT ) ; rootPanel . setContent ( rootLayout ) ; setCompositionRoot ( rootPanel ) ; configurationViews . forEach ( view -> view . addChangeListener ( this ) ) ; } | Init method adds all Configuration Views to the list of Views . | 300 | 12 |
29,274 | @ Override public ResponseEntity < InputStream > downloadArtifact ( @ PathVariable ( "softwareModuleId" ) final Long softwareModuleId , @ PathVariable ( "artifactId" ) final Long artifactId ) { final SoftwareModule module = softwareModuleManagement . get ( softwareModuleId ) . orElseThrow ( ( ) -> new EntityNotFoundException ( SoftwareModule . class , softwareModuleId ) ) ; final Artifact artifact = module . getArtifact ( artifactId ) . orElseThrow ( ( ) -> new EntityNotFoundException ( Artifact . class , artifactId ) ) ; final AbstractDbArtifact file = artifactManagement . loadArtifactBinary ( artifact . getSha1Hash ( ) ) . orElseThrow ( ( ) -> new ArtifactBinaryNotFoundException ( artifact . getSha1Hash ( ) ) ) ; final HttpServletRequest request = requestResponseContextHolder . getHttpServletRequest ( ) ; final String ifMatch = request . getHeader ( HttpHeaders . IF_MATCH ) ; if ( ifMatch != null && ! HttpUtil . matchesHttpHeader ( ifMatch , artifact . getSha1Hash ( ) ) ) { return new ResponseEntity <> ( HttpStatus . PRECONDITION_FAILED ) ; } return FileStreamingUtil . writeFileResponse ( file , artifact . getFilename ( ) , artifact . getCreatedAt ( ) , requestResponseContextHolder . getHttpServletResponse ( ) , request , null ) ; } | Handles the GET request for downloading an artifact . | 321 | 10 |
29,275 | public String putHeader ( final String name , final String value ) { if ( headers == null ) { headers = new TreeMap <> ( String . CASE_INSENSITIVE_ORDER ) ; } return headers . put ( name , value ) ; } | Associates the specified header value with the specified name . | 54 | 12 |
29,276 | public void setValue ( final Duration tenantDuration ) { if ( tenantDuration == null ) { // no tenant specific configuration checkBox . setValue ( false ) ; durationField . setDuration ( globalDuration ) ; durationField . setEnabled ( false ) ; return ; } checkBox . setValue ( true ) ; durationField . setDuration ( tenantDuration ) ; durationField . setEnabled ( true ) ; } | Set the value of the duration field | 84 | 7 |
29,277 | public Authentication doAuthenticate ( final DmfTenantSecurityToken securityToken ) { resolveTenant ( securityToken ) ; PreAuthenticatedAuthenticationToken authentication = new PreAuthenticatedAuthenticationToken ( null , null ) ; for ( final PreAuthenticationFilter filter : filterChain ) { final PreAuthenticatedAuthenticationToken authenticationRest = createAuthentication ( filter , securityToken ) ; if ( authenticationRest != null ) { authentication = authenticationRest ; authentication . setDetails ( new TenantAwareAuthenticationDetails ( securityToken . getTenant ( ) , true ) ) ; break ; } } return preAuthenticatedAuthenticationProvider . authenticate ( authentication ) ; } | Performs authentication with the security token . | 139 | 8 |
29,278 | public static void addTargetLinks ( final MgmtTarget response ) { response . add ( linkTo ( methodOn ( MgmtTargetRestApi . class ) . getAssignedDistributionSet ( response . getControllerId ( ) ) ) . withRel ( MgmtRestConstants . TARGET_V1_ASSIGNED_DISTRIBUTION_SET ) ) ; response . add ( linkTo ( methodOn ( MgmtTargetRestApi . class ) . getInstalledDistributionSet ( response . getControllerId ( ) ) ) . withRel ( MgmtRestConstants . TARGET_V1_INSTALLED_DISTRIBUTION_SET ) ) ; response . add ( linkTo ( methodOn ( MgmtTargetRestApi . class ) . getAttributes ( response . getControllerId ( ) ) ) . withRel ( MgmtRestConstants . TARGET_V1_ATTRIBUTES ) ) ; response . add ( linkTo ( methodOn ( MgmtTargetRestApi . class ) . getActionHistory ( response . getControllerId ( ) , 0 , MgmtRestConstants . REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE , ActionFields . ID . getFieldName ( ) + ":" + SortDirection . DESC , null ) ) . withRel ( MgmtRestConstants . TARGET_V1_ACTIONS ) . expand ( ) ) ; response . add ( linkTo ( methodOn ( MgmtTargetRestApi . class ) . getMetadata ( response . getControllerId ( ) , MgmtRestConstants . REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE , MgmtRestConstants . REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE , null , null ) ) . withRel ( "metadata" ) ) ; } | Add links to a target response . | 425 | 7 |
29,279 | public static List < MgmtTarget > toResponse ( final Collection < Target > targets ) { if ( targets == null ) { return Collections . emptyList ( ) ; } return new ResponseList <> ( targets . stream ( ) . map ( MgmtTargetMapper :: toResponse ) . collect ( Collectors . toList ( ) ) ) ; } | Create a response for targets . | 75 | 6 |
29,280 | public static MgmtTarget toResponse ( final Target target ) { if ( target == null ) { return null ; } final MgmtTarget targetRest = new MgmtTarget ( ) ; targetRest . setControllerId ( target . getControllerId ( ) ) ; targetRest . setDescription ( target . getDescription ( ) ) ; targetRest . setName ( target . getName ( ) ) ; targetRest . setUpdateStatus ( target . getUpdateStatus ( ) . name ( ) . toLowerCase ( ) ) ; final URI address = target . getAddress ( ) ; if ( address != null ) { if ( IpUtil . isIpAddresKnown ( address ) ) { targetRest . setIpAddress ( address . getHost ( ) ) ; } targetRest . setAddress ( address . toString ( ) ) ; } targetRest . setCreatedBy ( target . getCreatedBy ( ) ) ; targetRest . setLastModifiedBy ( target . getLastModifiedBy ( ) ) ; targetRest . setCreatedAt ( target . getCreatedAt ( ) ) ; targetRest . setLastModifiedAt ( target . getLastModifiedAt ( ) ) ; targetRest . setSecurityToken ( target . getSecurityToken ( ) ) ; targetRest . setRequestAttributes ( target . isRequestControllerAttributes ( ) ) ; // last target query is the last controller request date final Long lastTargetQuery = target . getLastTargetQuery ( ) ; final Long installationDate = target . getInstallationDate ( ) ; if ( lastTargetQuery != null ) { targetRest . setLastControllerRequestAt ( lastTargetQuery ) ; } if ( installationDate != null ) { targetRest . setInstalledAt ( installationDate ) ; } targetRest . add ( linkTo ( methodOn ( MgmtTargetRestApi . class ) . getTarget ( target . getControllerId ( ) ) ) . withSelfRel ( ) ) ; return targetRest ; } | Create a response for target . | 414 | 6 |
29,281 | private void selectDistributionSetValue ( ) { selectedDefaultDisSetType = ( Long ) combobox . getValue ( ) ; if ( ! selectedDefaultDisSetType . equals ( currentDefaultDisSetType ) ) { changeIcon . setVisible ( true ) ; notifyConfigurationChanged ( ) ; } else { changeIcon . setVisible ( false ) ; } } | Method that is called when combobox event is performed . | 78 | 12 |
29,282 | private void confirmAndForceAction ( final Long actionId ) { /* Display the confirmation */ final ConfirmationDialog confirmDialog = new ConfirmationDialog ( i18n . getMessage ( "caption.force.action.confirmbox" ) , i18n . getMessage ( "message.force.action.confirm" ) , i18n . getMessage ( UIMessageIdProvider . BUTTON_OK ) , i18n . getMessage ( UIMessageIdProvider . BUTTON_CANCEL ) , ok -> { if ( ! ok ) { return ; } deploymentManagement . forceTargetAction ( actionId ) ; populateAndUpdateTargetDetails ( selectedTarget ) ; notification . displaySuccess ( i18n . getMessage ( "message.force.action.success" ) ) ; } , UIComponentIdProvider . CONFIRMATION_POPUP_ID ) ; UI . getCurrent ( ) . addWindow ( confirmDialog . getWindow ( ) ) ; confirmDialog . getWindow ( ) . bringToFront ( ) ; } | Show confirmation window and if ok then only force the action . | 223 | 12 |
29,283 | private void confirmAndForceQuitAction ( final Long actionId ) { /* Display the confirmation */ final ConfirmationDialog confirmDialog = new ConfirmationDialog ( i18n . getMessage ( "caption.forcequit.action.confirmbox" ) , i18n . getMessage ( "message.forcequit.action.confirm" ) , i18n . getMessage ( UIMessageIdProvider . BUTTON_OK ) , i18n . getMessage ( UIMessageIdProvider . BUTTON_CANCEL ) , ok -> { if ( ! ok ) { return ; } final boolean cancelResult = forceQuitActiveAction ( actionId ) ; if ( cancelResult ) { populateAndUpdateTargetDetails ( selectedTarget ) ; notification . displaySuccess ( i18n . getMessage ( "message.forcequit.action.success" ) ) ; } else { notification . displayValidationError ( i18n . getMessage ( "message.forcequit.action.failed" ) ) ; } } , FontAwesome . WARNING , UIComponentIdProvider . CONFIRMATION_POPUP_ID , null ) ; UI . getCurrent ( ) . addWindow ( confirmDialog . getWindow ( ) ) ; confirmDialog . getWindow ( ) . bringToFront ( ) ; } | Show confirmation window and if ok then only force quit action . | 276 | 12 |
29,284 | private void updateDistributionTableStyle ( ) { managementUIState . getDistributionTableFilters ( ) . getPinnedTarget ( ) . ifPresent ( pinnedTarget -> { if ( pinnedTarget . getTargetId ( ) . equals ( selectedTarget . getId ( ) ) ) { eventBus . publish ( this , PinUnpinEvent . PIN_TARGET ) ; } } ) ; } | Update the colors of Assigned and installed distribution set in Target Pinning . | 83 | 15 |
29,285 | private void setColumnsSize ( final double min , final double max , final String ... columnPropertyIds ) { for ( final String columnPropertyId : columnPropertyIds ) { getColumn ( columnPropertyId ) . setMinimumWidth ( min ) ; getColumn ( columnPropertyId ) . setMaximumWidth ( max ) ; } } | Conveniently sets min - and max - width for a bunch of columns . | 70 | 16 |
29,286 | @ Scheduled ( initialDelayString = PROP_AUTO_CLEANUP_INTERVAL , fixedDelayString = PROP_AUTO_CLEANUP_INTERVAL ) public void run ( ) { LOGGER . debug ( "Auto cleanup scheduler has been triggered." ) ; // run this code in system code privileged to have the necessary // permission to query and create entities if ( ! cleanupTasks . isEmpty ( ) ) { systemSecurityContext . runAsSystem ( this :: executeAutoCleanup ) ; } } | Scheduler method which kicks off the cleanup process . | 112 | 11 |
29,287 | @ SuppressWarnings ( "squid:S3516" ) private Void executeAutoCleanup ( ) { systemManagement . forEachTenant ( tenant -> cleanupTasks . forEach ( task -> { final Lock lock = obtainLock ( task , tenant ) ; if ( ! lock . tryLock ( ) ) { return ; } try { task . run ( ) ; } catch ( final RuntimeException e ) { LOGGER . error ( "Cleanup task failed." , e ) ; } finally { lock . unlock ( ) ; } } ) ) ; return null ; } | Method which executes each registered cleanup task for each tenant . | 121 | 11 |
29,288 | public void styleDistributionSetTable ( final Long installedDistItemId , final Long assignedDistTableItemId ) { setCellStyleGenerator ( ( source , itemId , propertyId ) -> getPinnedDistributionStyle ( installedDistItemId , assignedDistTableItemId , itemId ) ) ; } | Added by Saumya Target pin listener . | 64 | 9 |
29,289 | private static FontIconData createFontIconData ( StatusFontIcon meta ) { FontIconData result = new FontIconData ( ) ; result . setFontIconHtml ( meta . getFontIcon ( ) . getHtml ( ) ) ; result . setTitle ( meta . getTitle ( ) ) ; result . setStyle ( meta . getStyle ( ) ) ; result . setId ( meta . getId ( ) ) ; result . setDisabled ( meta . isDisabled ( ) ) ; return result ; } | Creates a data transport object for the icon meta data . | 109 | 12 |
29,290 | public static List < String > getAllAuthorities ( ) { final List < String > allPermissions = new ArrayList <> ( ) ; final Field [ ] declaredFields = SpPermission . class . getDeclaredFields ( ) ; for ( final Field field : declaredFields ) { if ( Modifier . isPublic ( field . getModifiers ( ) ) && Modifier . isStatic ( field . getModifiers ( ) ) ) { field . setAccessible ( true ) ; try { final String role = ( String ) field . get ( null ) ; allPermissions . add ( role ) ; } catch ( final IllegalAccessException e ) { LOGGER . error ( e . getMessage ( ) , e ) ; } } } return allPermissions ; } | Return all permission . | 163 | 4 |
29,291 | @ SuppressWarnings ( { "squid:S1166" , "squid:S2221" } ) boolean isValidDragSource ( final VDragEvent drag , final UIDL configuration ) { try { final String dragSource = drag . getTransferable ( ) . getDragSource ( ) . getWidget ( ) . getElement ( ) . getId ( ) ; final String dragSourcePrefix = configuration . getStringAttribute ( DRAG_SOURCE ) ; if ( dragSource . startsWith ( dragSourcePrefix ) ) { return true ; } } catch ( final Exception e ) { // log and continue LOGGER . log ( Level . SEVERE , "Error verifying drag source: " + e . getLocalizedMessage ( ) ) ; } return false ; } | Exception semantics changes | 164 | 3 |
29,292 | @ RabbitListener ( queues = "${hawkbit.dmf.rabbitmq.authenticationReceiverQueue:authentication_receiver}" , containerFactory = "listenerContainerFactory" ) public Message onAuthenticationRequest ( final Message message ) { checkContentTypeJson ( message ) ; final SecurityContext oldContext = SecurityContextHolder . getContext ( ) ; try { return handleAuthenticationMessage ( message ) ; } catch ( final RuntimeException ex ) { throw new AmqpRejectAndDontRequeueException ( ex ) ; } finally { SecurityContextHolder . setContext ( oldContext ) ; } } | Executed on an authentication request . | 133 | 7 |
29,293 | private void checkIfArtifactIsAssignedToTarget ( final DmfTenantSecurityToken secruityToken , final String sha1Hash ) { if ( secruityToken . getControllerId ( ) != null ) { checkByControllerId ( sha1Hash , secruityToken . getControllerId ( ) ) ; } else if ( secruityToken . getTargetId ( ) != null ) { checkByTargetId ( sha1Hash , secruityToken . getTargetId ( ) ) ; } else { LOG . info ( "anonymous download no authentication check for artifact {}" , sha1Hash ) ; } } | check action for this download purposes the method will throw an EntityNotFoundException in case the controller is not allowed to download this file because it s not assigned to an action and not assigned to this controller . Otherwise no controllerId is set = anonymous download | 138 | 50 |
29,294 | public Long getTotalTargetCountByStatus ( final Status status ) { final Long count = statusTotalCountMap . get ( status ) ; return count == null ? 0L : count ; } | Gets the total target count from a state . | 39 | 10 |
29,295 | private void addToTotalCount ( final List < TotalTargetCountActionStatus > targetCountActionStatus ) { if ( targetCountActionStatus == null ) { statusTotalCountMap . put ( TotalTargetCountStatus . Status . NOTSTARTED , totalTargetCount ) ; return ; } statusTotalCountMap . put ( Status . RUNNING , 0L ) ; Long notStartedTargetCount = totalTargetCount ; for ( final TotalTargetCountActionStatus item : targetCountActionStatus ) { addToTotalCount ( item ) ; notStartedTargetCount -= item . getCount ( ) ; } statusTotalCountMap . put ( TotalTargetCountStatus . Status . NOTSTARTED , notStartedTargetCount ) ; } | Populate all target status to a the given map | 151 | 10 |
29,296 | @ SuppressWarnings ( "squid:MethodCyclomaticComplexity" ) private Status convertStatus ( final Action . Status status ) { switch ( status ) { case SCHEDULED : return Status . SCHEDULED ; case ERROR : return Status . ERROR ; case FINISHED : return Status . FINISHED ; case CANCELED : return Status . CANCELLED ; case RETRIEVED : case RUNNING : case WARNING : case DOWNLOAD : case CANCELING : return Status . RUNNING ; case DOWNLOADED : return Action . ActionType . DOWNLOAD_ONLY . equals ( rolloutType ) ? Status . FINISHED : Status . RUNNING ; default : throw new IllegalArgumentException ( "State " + status + "is not valid" ) ; } } | really complex . | 172 | 3 |
29,297 | public void populateModule ( final DistributionSet distributionSet ) { removeAllItems ( ) ; if ( distributionSet != null ) { if ( isUnassignSoftModAllowed && permissionChecker . hasUpdateRepositoryPermission ( ) ) { try { isTargetAssigned = false ; } catch ( final EntityReadOnlyException exception ) { isTargetAssigned = true ; LOG . info ( "Target already assigned for the distribution set: " + distributionSet . getName ( ) , exception ) ; } } final Set < SoftwareModuleType > swModuleMandatoryTypes = distributionSet . getType ( ) . getMandatoryModuleTypes ( ) ; final Set < SoftwareModuleType > swModuleOptionalTypes = distributionSet . getType ( ) . getOptionalModuleTypes ( ) ; if ( ! CollectionUtils . isEmpty ( swModuleMandatoryTypes ) ) { swModuleMandatoryTypes . forEach ( swModule -> setSwModuleProperties ( swModule , true , distributionSet ) ) ; } if ( ! CollectionUtils . isEmpty ( swModuleOptionalTypes ) ) { swModuleOptionalTypes . forEach ( swModule -> setSwModuleProperties ( swModule , false , distributionSet ) ) ; } setAmountOfTableRows ( getContainerDataSource ( ) . size ( ) ) ; } } | Populate software module table . | 275 | 6 |
29,298 | protected Label buildTitleLabel ( ) { // create default title - even shown when no data is available title = new LabelBuilder ( ) . name ( titleText ) . buildCaptionLabel ( ) ; title . setImmediate ( true ) ; title . setContentMode ( ContentMode . HTML ) ; return title ; } | Builds the title label . | 66 | 6 |
29,299 | protected HorizontalLayout buildTitleLayout ( ) { titleLayout = new HorizontalLayout ( ) ; titleLayout . addStyleName ( SPUIStyleDefinitions . WIDGET_TITLE ) ; titleLayout . setSpacing ( false ) ; titleLayout . setMargin ( false ) ; titleLayout . setSizeFull ( ) ; titleLayout . addComponent ( title ) ; titleLayout . setComponentAlignment ( title , Alignment . TOP_LEFT ) ; titleLayout . setExpandRatio ( title , 0.8F ) ; if ( hasHeaderMaximizeSupport ( ) ) { titleLayout . addComponents ( getHeaderMaximizeSupport ( ) . maxMinButton ) ; titleLayout . setComponentAlignment ( getHeaderMaximizeSupport ( ) . maxMinButton , Alignment . TOP_RIGHT ) ; titleLayout . setExpandRatio ( getHeaderMaximizeSupport ( ) . maxMinButton , 0.2F ) ; } return titleLayout ; } | Builds the title layout . | 210 | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.