idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
144,800 | private void initPatternButtonGroup ( ) { m_groupPattern = new CmsRadioButtonGroup ( ) ; m_patternButtons = new HashMap <> ( ) ; createAndAddButton ( PatternType . DAILY , Messages . GUI_SERIALDATE_TYPE_DAILY_0 ) ; m_patternButtons . put ( PatternType . NONE , m_patternButtons . get ( PatternType . DAILY ) ) ; createAndAddButton ( PatternType . WEEKLY , Messages . GUI_SERIALDATE_TYPE_WEEKLY_0 ) ; createAndAddButton ( PatternType . MONTHLY , Messages . GUI_SERIALDATE_TYPE_MONTHLY_0 ) ; createAndAddButton ( PatternType . YEARLY , Messages . GUI_SERIALDATE_TYPE_YEARLY_0 ) ; // createAndAddButton(PatternType.INDIVIDUAL, Messages.GUI_SERIALDATE_TYPE_INDIVIDUAL_0); m_groupPattern . addValueChangeHandler ( new ValueChangeHandler < String > ( ) { public void onValueChange ( ValueChangeEvent < String > event ) { if ( handleChange ( ) ) { String value = event . getValue ( ) ; if ( value != null ) { m_controller . setPattern ( value ) ; } } } } ) ; } | Initialize the pattern choice button group . | 292 | 8 |
144,801 | private void injectAdditionalStyles ( ) { try { Collection < String > stylesheets = OpenCms . getWorkplaceAppManager ( ) . getAdditionalStyleSheets ( ) ; for ( String stylesheet : stylesheets ) { A_CmsUI . get ( ) . getPage ( ) . addDependency ( new Dependency ( Type . STYLESHEET , stylesheet ) ) ; } } catch ( Exception e ) { LOG . warn ( e . getLocalizedMessage ( ) , e ) ; } } | Inject external stylesheets . | 113 | 7 |
144,802 | public String createSessionForResource ( String configPath , String fileName ) throws CmsUgcException { CmsUgcSession formSession = CmsUgcSessionFactory . getInstance ( ) . createSessionForFile ( getCmsObject ( ) , getRequest ( ) , configPath , fileName ) ; return "" + formSession . getId ( ) ; } | Creates a new form session to edit the file with the given name using the given form configuration . | 78 | 20 |
144,803 | public final void setValue ( String value ) { if ( ( null == value ) || value . isEmpty ( ) ) { setDefaultValue ( ) ; } else { try { tryToSetParsedValue ( value ) ; } catch ( @ SuppressWarnings ( "unused" ) Exception e ) { CmsDebugLog . consoleLog ( "Could not set invalid serial date value: " + value ) ; setDefaultValue ( ) ; } } notifyOnValueChange ( ) ; } | Set the value as provided . | 105 | 6 |
144,804 | private JSONValue datesToJsonArray ( Collection < Date > dates ) { if ( null != dates ) { JSONArray result = new JSONArray ( ) ; for ( Date d : dates ) { result . set ( result . size ( ) , dateToJson ( d ) ) ; } return result ; } return null ; } | Converts a collection of dates to a JSON array with the long representation of the dates as strings . | 69 | 20 |
144,805 | private JSONValue dateToJson ( Date d ) { return null != d ? new JSONString ( Long . toString ( d . getTime ( ) ) ) : null ; } | Convert a date to the String representation we use in the JSON . | 38 | 14 |
144,806 | private Boolean readOptionalBoolean ( JSONValue val ) { JSONBoolean b = null == val ? null : val . isBoolean ( ) ; if ( b != null ) { return Boolean . valueOf ( b . booleanValue ( ) ) ; } return null ; } | Read an optional boolean value form a JSON value . | 57 | 10 |
144,807 | private Date readOptionalDate ( JSONValue val ) { JSONString str = null == val ? null : val . isString ( ) ; if ( str != null ) { try { return new Date ( Long . parseLong ( str . stringValue ( ) ) ) ; } catch ( @ SuppressWarnings ( "unused" ) NumberFormatException e ) { // do nothing - return the default value } } return null ; } | Read an optional Date value form a JSON value . | 90 | 10 |
144,808 | private int readOptionalInt ( JSONValue val ) { JSONString str = null == val ? null : val . isString ( ) ; if ( str != null ) { try { return Integer . valueOf ( str . stringValue ( ) ) . intValue ( ) ; } catch ( @ SuppressWarnings ( "unused" ) NumberFormatException e ) { // Do nothing, return default value } } return 0 ; } | Read an optional int value form a JSON value . | 90 | 10 |
144,809 | private Month readOptionalMonth ( JSONValue val ) { String str = readOptionalString ( val ) ; if ( null != str ) { try { return Month . valueOf ( str ) ; } catch ( @ SuppressWarnings ( "unused" ) IllegalArgumentException e ) { // Do nothing -return the default value } } return null ; } | Read an optional month value form a JSON value . | 75 | 10 |
144,810 | private String readOptionalString ( JSONValue val ) { JSONString str = null == val ? null : val . isString ( ) ; if ( str != null ) { return str . stringValue ( ) ; } return null ; } | Read an optional string value form a JSON value . | 48 | 10 |
144,811 | private WeekDay readWeekDay ( JSONValue val ) throws IllegalArgumentException { String str = readOptionalString ( val ) ; if ( null != str ) { return WeekDay . valueOf ( str ) ; } throw new IllegalArgumentException ( ) ; } | Read a single weekday from the provided JSON value . | 55 | 10 |
144,812 | private JSONValue toJsonStringList ( Collection < ? extends Object > list ) { if ( null != list ) { JSONArray array = new JSONArray ( ) ; for ( Object o : list ) { array . set ( array . size ( ) , new JSONString ( o . toString ( ) ) ) ; } return array ; } else { return null ; } } | Convert a list of objects to a JSON array with the string representations of that objects . | 78 | 18 |
144,813 | private void tryToSetParsedValue ( String value ) throws Exception { JSONObject json = JSONParser . parseStrict ( value ) . isObject ( ) ; JSONValue val = json . get ( JsonKey . START ) ; setStart ( readOptionalDate ( val ) ) ; val = json . get ( JsonKey . END ) ; setEnd ( readOptionalDate ( val ) ) ; setWholeDay ( readOptionalBoolean ( json . get ( JsonKey . WHOLE_DAY ) ) ) ; JSONObject patternJson = json . get ( JsonKey . PATTERN ) . isObject ( ) ; readPattern ( patternJson ) ; setExceptions ( readDates ( json . get ( JsonKey . EXCEPTIONS ) ) ) ; setSeriesEndDate ( readOptionalDate ( json . get ( JsonKey . SERIES_ENDDATE ) ) ) ; setOccurrences ( readOptionalInt ( json . get ( JsonKey . SERIES_OCCURRENCES ) ) ) ; setDerivedEndType ( ) ; setCurrentTillEnd ( readOptionalBoolean ( json . get ( JsonKey . CURRENT_TILL_END ) ) ) ; setParentSeriesId ( readOptionalUUID ( json . get ( JsonKey . PARENT_SERIES ) ) ) ; } | Try to set the value from the provided Json string . | 287 | 12 |
144,814 | private static List < CmsCategory > getCategories ( CmsObject cms , CmsResource resource ) { if ( ( null != resource ) && ( null != cms ) ) { try { return CmsCategoryService . getInstance ( ) . readResourceCategories ( cms , resource ) ; } catch ( CmsException e ) { LOG . error ( e . getLocalizedMessage ( ) , e ) ; } } return new ArrayList < CmsCategory > ( 0 ) ; } | Reads the categories for the given resource . | 105 | 9 |
144,815 | public List < CmsCategory > getLeafItems ( ) { List < CmsCategory > result = new ArrayList < CmsCategory > ( ) ; if ( m_categories . isEmpty ( ) ) { return result ; } Iterator < CmsCategory > it = m_categories . iterator ( ) ; CmsCategory current = it . next ( ) ; while ( it . hasNext ( ) ) { CmsCategory next = it . next ( ) ; if ( ! next . getPath ( ) . startsWith ( current . getPath ( ) ) ) { result . add ( current ) ; } current = next ; } result . add ( current ) ; return result ; } | Returns only the leaf categories of the wrapped categories . | 146 | 10 |
144,816 | public Map < String , CmsJspCategoryAccessBean > getSubCategories ( ) { if ( m_subCategories == null ) { m_subCategories = CmsCollectionsGenericWrapper . createLazyMap ( new Transformer ( ) { @ SuppressWarnings ( "synthetic-access" ) public Object transform ( Object pathPrefix ) { return new CmsJspCategoryAccessBean ( m_cms , m_categories , ( String ) pathPrefix ) ; } } ) ; } return m_subCategories ; } | Returns a map from a category path to the wrapper of all the sub - categories of the category with the path given as key . | 123 | 26 |
144,817 | public List < CmsCategory > getTopItems ( ) { List < CmsCategory > categories = new ArrayList < CmsCategory > ( ) ; String matcher = Pattern . quote ( m_mainCategoryPath ) + "[^/]*/" ; for ( CmsCategory category : m_categories ) { if ( category . getPath ( ) . matches ( matcher ) ) { categories . add ( category ) ; } } return categories ; } | Returns all categories that are direct children of the current main category . | 96 | 13 |
144,818 | public void addHiDpiImage ( String factor , CmsJspImageBean image ) { if ( m_hiDpiImages == null ) { m_hiDpiImages = CmsCollectionsGenericWrapper . createLazyMap ( new CmsScaleHiDpiTransformer ( ) ) ; } m_hiDpiImages . put ( factor , image ) ; } | adds a CmsJspImageBean as hi - DPI variant to this image | 82 | 19 |
144,819 | public static final String [ ] getRequiredSolrFields ( ) { if ( null == m_requiredSolrFields ) { List < Locale > locales = OpenCms . getLocaleManager ( ) . getAvailableLocales ( ) ; m_requiredSolrFields = new String [ 14 + ( locales . size ( ) * 6 ) ] ; int count = 0 ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_PATH ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_TYPE ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_DATE_CREATED ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_DATE_LASTMODIFIED ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_DATE_EXPIRED ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_DATE_RELEASED ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_SIZE ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_STATE ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_USER_CREATED ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_ID ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_USER_LAST_MODIFIED ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_ADDITIONAL_INFO ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_CONTAINER_TYPES ; m_requiredSolrFields [ count ++ ] = CmsSearchField . FIELD_RESOURCE_LOCALES ; for ( Locale locale : locales ) { m_requiredSolrFields [ count ++ ] = CmsSearchFieldConfiguration . getLocaleExtendedName ( CmsSearchField . FIELD_TITLE_UNSTORED , locale . toString ( ) ) + "_s" ; m_requiredSolrFields [ count ++ ] = CmsSearchFieldConfiguration . getLocaleExtendedName ( CmsPropertyDefinition . PROPERTY_TITLE , locale . toString ( ) ) + CmsSearchField . FIELD_DYNAMIC_PROPERTIES_DIRECT + "_s" ; m_requiredSolrFields [ count ++ ] = CmsPropertyDefinition . PROPERTY_TITLE + CmsSearchField . FIELD_DYNAMIC_PROPERTIES_DIRECT + "_s" ; m_requiredSolrFields [ count ++ ] = CmsSearchFieldConfiguration . getLocaleExtendedName ( CmsSearchField . FIELD_DESCRIPTION , locale . toString ( ) ) + "_s" ; m_requiredSolrFields [ count ++ ] = CmsSearchFieldConfiguration . getLocaleExtendedName ( CmsPropertyDefinition . PROPERTY_DESCRIPTION , locale . toString ( ) ) + CmsSearchField . FIELD_DYNAMIC_PROPERTIES + "_s" ; m_requiredSolrFields [ count ++ ] = CmsPropertyDefinition . PROPERTY_DESCRIPTION + CmsSearchField . FIELD_DYNAMIC_PROPERTIES + "_s" ; } } return m_requiredSolrFields ; } | Returns the list of Solr fields a search result must have to initialize the gallery search result correctly . | 789 | 20 |
144,820 | private static CmsUUID toUuid ( String uuid ) { if ( "null" . equals ( uuid ) || CmsStringUtil . isEmpty ( uuid ) ) { return null ; } return new CmsUUID ( uuid ) ; } | Converts string to UUID and returns it or null if the conversion is not possible . | 57 | 18 |
144,821 | private void ensureIndexIsUnlocked ( String dataDir ) { Collection < File > lockFiles = new ArrayList < File > ( 2 ) ; lockFiles . add ( new File ( CmsFileUtil . addTrailingSeparator ( CmsFileUtil . addTrailingSeparator ( dataDir ) + "index" ) + "write.lock" ) ) ; lockFiles . add ( new File ( CmsFileUtil . addTrailingSeparator ( CmsFileUtil . addTrailingSeparator ( dataDir ) + "spellcheck" ) + "write.lock" ) ) ; for ( File lockFile : lockFiles ) { if ( lockFile . exists ( ) ) { lockFile . delete ( ) ; LOG . warn ( "Forcely unlocking index with data dir \"" + dataDir + "\" by removing file \"" + lockFile . getAbsolutePath ( ) + "\"." ) ; } } } | Remove write . lock file in the data directory to ensure the index is unlocked . | 204 | 16 |
144,822 | private void maybeUpdateScrollbarPositions ( ) { if ( ! isAttached ( ) ) { return ; } if ( m_scrollbar != null ) { int vPos = getVerticalScrollPosition ( ) ; if ( m_scrollbar . getVerticalScrollPosition ( ) != vPos ) { m_scrollbar . setVerticalScrollPosition ( vPos ) ; } } } | Synchronize the scroll positions of the scrollbars with the actual scroll position of the content . | 83 | 19 |
144,823 | private void setVerticalScrollbar ( final CmsScrollBar scrollbar , int width ) { // Validate. if ( ( scrollbar == m_scrollbar ) || ( scrollbar == null ) ) { return ; } // Detach new child. scrollbar . asWidget ( ) . removeFromParent ( ) ; // Remove old child. if ( m_scrollbar != null ) { if ( m_verticalScrollbarHandlerRegistration != null ) { m_verticalScrollbarHandlerRegistration . removeHandler ( ) ; m_verticalScrollbarHandlerRegistration = null ; } remove ( m_scrollbar ) ; } m_scrollLayer . appendChild ( scrollbar . asWidget ( ) . getElement ( ) ) ; adopt ( scrollbar . asWidget ( ) ) ; // Logical attach. m_scrollbar = scrollbar ; m_verticalScrollbarWidth = width ; // Initialize the new scrollbar. m_verticalScrollbarHandlerRegistration = scrollbar . addValueChangeHandler ( new ValueChangeHandler < Integer > ( ) { public void onValueChange ( ValueChangeEvent < Integer > event ) { int vPos = scrollbar . getVerticalScrollPosition ( ) ; int v = getVerticalScrollPosition ( ) ; if ( v != vPos ) { setVerticalScrollPosition ( vPos ) ; } } } ) ; maybeUpdateScrollbars ( ) ; } | Set the scrollbar used for vertical scrolling . | 294 | 9 |
144,824 | public boolean detectBlackBerryHigh ( ) { //Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser if ( detectBlackBerryWebKit ( ) ) { return false ; } if ( detectBlackBerry ( ) ) { if ( detectBlackBerryTouch ( ) || ( userAgent . indexOf ( deviceBBBold ) != - 1 ) || ( userAgent . indexOf ( deviceBBTour ) != - 1 ) || ( userAgent . indexOf ( deviceBBCurve ) != - 1 ) ) { return true ; } else { return false ; } } else { return false ; } } | Detects if the current browser is a BlackBerry device AND has a more capable recent browser . Excludes the Playbook . Examples Storm Bold Tour Curve2 Excludes the new BlackBerry OS 6 and 7 browser!! | 127 | 41 |
144,825 | public boolean detectBlackBerryTouch ( ) { if ( detectBlackBerry ( ) && ( ( userAgent . indexOf ( deviceBBStorm ) != - 1 ) || ( userAgent . indexOf ( deviceBBTorch ) != - 1 ) || ( userAgent . indexOf ( deviceBBBoldTouch ) != - 1 ) || ( userAgent . indexOf ( deviceBBCurveTouch ) != - 1 ) ) ) { return true ; } return false ; } | Detects if the current browser is a BlackBerry Touch device such as the Storm Torch and Bold Touch . Excludes the Playbook . | 97 | 26 |
144,826 | public boolean detectMobileQuick ( ) { //Let's exclude tablets if ( isTierTablet ) { return false ; } //Most mobile browsing is done on smartphones if ( detectSmartphone ( ) ) { return true ; } //Catch-all for many mobile devices if ( userAgent . indexOf ( mobile ) != - 1 ) { return true ; } if ( detectOperaMobile ( ) ) { return true ; } //We also look for Kindle devices if ( detectKindle ( ) || detectAmazonSilk ( ) ) { return true ; } if ( detectWapWml ( ) || detectMidpCapable ( ) || detectBrewDevice ( ) ) { return true ; } if ( ( userAgent . indexOf ( engineNetfront ) != - 1 ) || ( userAgent . indexOf ( engineUpBrowser ) != - 1 ) ) { return true ; } return false ; } | Detects if the current device is a mobile device . This method catches most of the popular modern devices . Excludes Apple iPads and other modern tablets . | 187 | 30 |
144,827 | public boolean detectNintendo ( ) { if ( ( userAgent . indexOf ( deviceNintendo ) != - 1 ) || ( userAgent . indexOf ( deviceWii ) != - 1 ) || ( userAgent . indexOf ( deviceNintendoDs ) != - 1 ) ) { return true ; } return false ; } | Detects if the current device is a Nintendo game device . | 65 | 12 |
144,828 | public boolean detectOperaMobile ( ) { if ( ( userAgent . indexOf ( engineOpera ) != - 1 ) && ( ( userAgent . indexOf ( mini ) != - 1 ) || ( userAgent . indexOf ( mobi ) != - 1 ) ) ) { return true ; } return false ; } | Detects Opera Mobile or Opera Mini . | 67 | 8 |
144,829 | public boolean detectSonyMylo ( ) { if ( ( userAgent . indexOf ( manuSony ) != - 1 ) && ( ( userAgent . indexOf ( qtembedded ) != - 1 ) || ( userAgent . indexOf ( mylocom2 ) != - 1 ) ) ) { return true ; } return false ; } | Detects if the current browser is a Sony Mylo device . | 73 | 13 |
144,830 | public boolean detectTierIphone ( ) { if ( detectIphoneOrIpod ( ) || detectAndroidPhone ( ) || detectWindowsPhone ( ) || detectBlackBerry10Phone ( ) || ( detectBlackBerryWebKit ( ) && detectBlackBerryTouch ( ) ) || detectPalmWebOS ( ) || detectBada ( ) || detectTizen ( ) || detectFirefoxOSPhone ( ) || detectSailfishPhone ( ) || detectUbuntuPhone ( ) || detectGamingHandheld ( ) ) { return true ; } return false ; } | The quick way to detect for a tier of devices . This method detects for devices which can display iPhone - optimized web content . Includes iPhone iPod Touch Android Windows Phone 7 and 8 BB10 WebOS Playstation Vita etc . | 116 | 43 |
144,831 | public boolean detectTierRichCss ( ) { boolean result = false ; //The following devices are explicitly ok. //Note: 'High' BlackBerry devices ONLY if ( detectMobileQuick ( ) ) { //Exclude iPhone Tier and e-Ink Kindle devices. if ( ! detectTierIphone ( ) && ! detectKindle ( ) ) { //The following devices are explicitly ok. //Note: 'High' BlackBerry devices ONLY //Older Windows 'Mobile' isn't good enough for iPhone Tier. if ( detectWebkit ( ) || detectS60OssBrowser ( ) || detectBlackBerryHigh ( ) || detectWindowsMobile ( ) || ( userAgent . indexOf ( engineTelecaQ ) != - 1 ) ) { result = true ; } // if detectWebkit() } //if !detectTierIphone() } //if detectMobileQuick() return result ; } | The quick way to detect for a tier of devices . This method detects for devices which are likely to be capable of viewing CSS content optimized for the iPhone but may not necessarily support JavaScript . Excludes all iPhone Tier devices . | 184 | 44 |
144,832 | private void setCorrectDay ( Calendar date ) { if ( monthHasNotDay ( date ) ) { date . set ( Calendar . DAY_OF_MONTH , date . getActualMaximum ( Calendar . DAY_OF_MONTH ) ) ; } else { date . set ( Calendar . DAY_OF_MONTH , m_dayOfMonth ) ; } } | Set the correct day for the date with year and month already fixed . | 77 | 14 |
144,833 | public String getDbProperty ( String key ) { // extract the database key out of the entire key String databaseKey = key . substring ( 0 , key . indexOf ( ' ' ) ) ; Properties databaseProperties = getDatabaseProperties ( ) . get ( databaseKey ) ; return databaseProperties . getProperty ( key , "" ) ; } | Returns the value for a given key from the database properties . | 73 | 12 |
144,834 | public String isChecked ( String value1 , String value2 ) { if ( ( value1 == null ) || ( value2 == null ) ) { return "" ; } if ( value1 . trim ( ) . equalsIgnoreCase ( value2 . trim ( ) ) ) { return "checked" ; } return "" ; } | Over simplistic helper to compare two strings to check radio buttons . | 69 | 12 |
144,835 | public boolean canLockBecauseOfInactivity ( CmsObject cms , CmsUser user ) { return ! user . isManaged ( ) && ! user . isWebuser ( ) && ! OpenCms . getDefaultUsers ( ) . isDefaultUser ( user . getName ( ) ) && ! OpenCms . getRoleManager ( ) . hasRole ( cms , user . getName ( ) , CmsRole . ROOT_ADMIN ) ; } | Checks whether a user account can be locked because of inactivity . | 99 | 14 |
144,836 | private void addDownloadButton ( final CmsLogFileView view ) { Button button = CmsToolBar . createButton ( FontOpenCms . DOWNLOAD , CmsVaadinUtils . getMessageText ( Messages . GUI_LOGFILE_DOWNLOAD_0 ) ) ; button . addClickListener ( new ClickListener ( ) { private static final long serialVersionUID = 1L ; public void buttonClick ( ClickEvent event ) { Window window = CmsBasicDialog . prepareWindow ( CmsBasicDialog . DialogWidth . wide ) ; window . setCaption ( CmsVaadinUtils . getMessageText ( Messages . GUI_LOGFILE_DOWNLOAD_0 ) ) ; window . setContent ( new CmsLogDownloadDialog ( window , view . getCurrentFile ( ) ) ) ; A_CmsUI . get ( ) . addWindow ( window ) ; } } ) ; m_uiContext . addToolbarButton ( button ) ; } | Adds the download button . | 204 | 5 |
144,837 | @ SuppressWarnings ( "unchecked" ) public static boolean addPropertyDefault ( PropertiesImpl props , PropertyDefinition < ? > propDef ) { if ( ( props == null ) || ( props . getProperties ( ) == null ) ) { throw new IllegalArgumentException ( "Props must not be null!" ) ; } if ( propDef == null ) { return false ; } List < ? > defaultValue = propDef . getDefaultValue ( ) ; if ( ( defaultValue != null ) && ( ! defaultValue . isEmpty ( ) ) ) { switch ( propDef . getPropertyType ( ) ) { case BOOLEAN : props . addProperty ( new PropertyBooleanImpl ( propDef . getId ( ) , ( List < Boolean > ) defaultValue ) ) ; break ; case DATETIME : props . addProperty ( new PropertyDateTimeImpl ( propDef . getId ( ) , ( List < GregorianCalendar > ) defaultValue ) ) ; break ; case DECIMAL : props . addProperty ( new PropertyDecimalImpl ( propDef . getId ( ) , ( List < BigDecimal > ) defaultValue ) ) ; break ; case HTML : props . addProperty ( new PropertyHtmlImpl ( propDef . getId ( ) , ( List < String > ) defaultValue ) ) ; break ; case ID : props . addProperty ( new PropertyIdImpl ( propDef . getId ( ) , ( List < String > ) defaultValue ) ) ; break ; case INTEGER : props . addProperty ( new PropertyIntegerImpl ( propDef . getId ( ) , ( List < BigInteger > ) defaultValue ) ) ; break ; case STRING : props . addProperty ( new PropertyStringImpl ( propDef . getId ( ) , ( List < String > ) defaultValue ) ) ; break ; case URI : props . addProperty ( new PropertyUriImpl ( propDef . getId ( ) , ( List < String > ) defaultValue ) ) ; break ; default : throw new RuntimeException ( "Unknown datatype! Spec change?" ) ; } return true ; } return false ; } | Adds the default value of property if defined . | 453 | 9 |
144,838 | public static boolean checkAddProperty ( CmsCmisTypeManager typeManager , Properties properties , String typeId , Set < String > filter , String id ) { if ( ( properties == null ) || ( properties . getProperties ( ) == null ) ) { throw new IllegalArgumentException ( "Properties must not be null!" ) ; } if ( id == null ) { throw new IllegalArgumentException ( "Id must not be null!" ) ; } TypeDefinition type = typeManager . getType ( typeId ) ; if ( type == null ) { throw new IllegalArgumentException ( "Unknown type: " + typeId ) ; } if ( ! type . getPropertyDefinitions ( ) . containsKey ( id ) ) { throw new IllegalArgumentException ( "Unknown property: " + id ) ; } String queryName = type . getPropertyDefinitions ( ) . get ( id ) . getQueryName ( ) ; if ( ( queryName != null ) && ( filter != null ) ) { if ( ! filter . contains ( queryName ) ) { return false ; } else { filter . remove ( queryName ) ; } } return true ; } | Checks whether a property can be added to a Properties . | 243 | 12 |
144,839 | public static GregorianCalendar millisToCalendar ( long millis ) { GregorianCalendar result = new GregorianCalendar ( ) ; result . setTimeZone ( TimeZone . getTimeZone ( "GMT" ) ) ; result . setTimeInMillis ( ( long ) ( Math . ceil ( millis / 1000 ) * 1000 ) ) ; return result ; } | Converts milliseconds into a calendar object . | 81 | 8 |
144,840 | private void updateGhostStyle ( ) { if ( CmsStringUtil . isEmpty ( m_realValue ) ) { if ( CmsStringUtil . isEmpty ( m_ghostValue ) ) { updateTextArea ( m_realValue ) ; return ; } if ( ! m_focus ) { setGhostStyleEnabled ( true ) ; updateTextArea ( m_ghostValue ) ; } else { // don't show ghost mode while focused setGhostStyleEnabled ( false ) ; } } else { setGhostStyleEnabled ( false ) ; updateTextArea ( m_realValue ) ; } } | Updates the styling and content of the internal text area based on the real value the ghost value and whether it has focus . | 126 | 25 |
144,841 | private Map < String , String > generateCommonConfigPart ( ) { Map < String , String > result = new HashMap <> ( ) ; if ( m_category != null ) { result . put ( CONFIGURATION_CATEGORY , m_category ) ; } // append 'only leafs' to configuration if ( m_onlyLeafs ) { result . put ( CONFIGURATION_ONLYLEAFS , null ) ; } // append 'property' to configuration if ( m_property != null ) { result . put ( CONFIGURATION_PROPERTY , m_property ) ; } // append 'selectionType' to configuration if ( m_selectiontype != null ) { result . put ( CONFIGURATION_SELECTIONTYPE , m_selectiontype ) ; } return result ; } | Helper to generate the common configuration part for client - side and server - side widget . | 170 | 17 |
144,842 | public Map < TimestampMode , List < String > > getDefaultTimestampModes ( ) { Map < TimestampMode , List < String > > result = new HashMap < TimestampMode , List < String > > ( ) ; for ( String resourcetype : m_defaultTimestampModes . keySet ( ) ) { TimestampMode mode = m_defaultTimestampModes . get ( resourcetype ) ; if ( result . containsKey ( mode ) ) { result . get ( mode ) . add ( resourcetype ) ; } else { List < String > list = new ArrayList < String > ( ) ; list . add ( resourcetype ) ; result . put ( mode , list ) ; } } return result ; } | Returns the map from resourcetype names to default timestamp modes . | 166 | 15 |
144,843 | protected < H extends EventHandler > HandlerRegistration addHandler ( final H handler , GwtEvent . Type < H > type ) { return ensureHandlers ( ) . addHandlerToSource ( type , this , handler ) ; } | Adds this handler to the widget . | 47 | 7 |
144,844 | protected List < I_CmsFacetQueryItem > parseFacetQueryItems ( final String path ) throws Exception { final List < I_CmsXmlContentValue > values = m_xml . getValues ( path , m_locale ) ; if ( values == null ) { return null ; } else { List < I_CmsFacetQueryItem > parsedItems = new ArrayList < I_CmsFacetQueryItem > ( values . size ( ) ) ; for ( I_CmsXmlContentValue value : values ) { I_CmsFacetQueryItem item = parseFacetQueryItem ( value . getPath ( ) + "/" ) ; if ( null != item ) { parsedItems . add ( item ) ; } else { // TODO: log } } return parsedItems ; } } | Helper to read a mandatory String value list . | 175 | 9 |
144,845 | protected I_CmsSearchConfigurationFacetField parseFieldFacet ( final String pathPrefix ) { try { final String field = parseMandatoryStringValue ( pathPrefix + XML_ELEMENT_FACET_FIELD ) ; final String name = parseOptionalStringValue ( pathPrefix + XML_ELEMENT_FACET_NAME ) ; final String label = parseOptionalStringValue ( pathPrefix + XML_ELEMENT_FACET_LABEL ) ; final Integer minCount = parseOptionalIntValue ( pathPrefix + XML_ELEMENT_FACET_MINCOUNT ) ; final Integer limit = parseOptionalIntValue ( pathPrefix + XML_ELEMENT_FACET_LIMIT ) ; final String prefix = parseOptionalStringValue ( pathPrefix + XML_ELEMENT_FACET_PREFIX ) ; final String sorder = parseOptionalStringValue ( pathPrefix + XML_ELEMENT_FACET_ORDER ) ; I_CmsSearchConfigurationFacet . SortOrder order ; try { order = I_CmsSearchConfigurationFacet . SortOrder . valueOf ( sorder ) ; } catch ( @ SuppressWarnings ( "unused" ) final Exception e ) { order = null ; } final String filterQueryModifier = parseOptionalStringValue ( pathPrefix + XML_ELEMENT_FACET_FILTERQUERYMODIFIER ) ; final Boolean isAndFacet = parseOptionalBooleanValue ( pathPrefix + XML_ELEMENT_FACET_ISANDFACET ) ; final List < String > preselection = parseOptionalStringValues ( pathPrefix + XML_ELEMENT_FACET_PRESELECTION ) ; final Boolean ignoreAllFacetFilters = parseOptionalBooleanValue ( pathPrefix + XML_ELEMENT_FACET_IGNOREALLFACETFILTERS ) ; return new CmsSearchConfigurationFacetField ( field , name , minCount , limit , prefix , label , order , filterQueryModifier , isAndFacet , preselection , ignoreAllFacetFilters ) ; } catch ( final Exception e ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERR_FIELD_FACET_MANDATORY_KEY_MISSING_1 , XML_ELEMENT_FACET_FIELD ) , e ) ; return null ; } } | Reads the configuration of a field facet . | 537 | 9 |
144,846 | protected Boolean parseOptionalBooleanValue ( final String path ) { final I_CmsXmlContentValue value = m_xml . getValue ( path , m_locale ) ; if ( value == null ) { return null ; } else { final String stringValue = value . getStringValue ( null ) ; try { final Boolean boolValue = Boolean . valueOf ( stringValue ) ; return boolValue ; } catch ( final NumberFormatException e ) { LOG . info ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_OPTIONAL_BOOLEAN_MISSING_1 , path ) , e ) ; return null ; } } } | Helper to read an optional Boolean value . | 145 | 8 |
144,847 | protected Integer parseOptionalIntValue ( final String path ) { final I_CmsXmlContentValue value = m_xml . getValue ( path , m_locale ) ; if ( value == null ) { return null ; } else { final String stringValue = value . getStringValue ( null ) ; try { final Integer intValue = Integer . valueOf ( stringValue ) ; return intValue ; } catch ( final NumberFormatException e ) { LOG . info ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_OPTIONAL_INTEGER_MISSING_1 , path ) , e ) ; return null ; } } } | Helper to read an optional Integer value . | 143 | 8 |
144,848 | protected String parseOptionalStringValue ( final String path ) { final I_CmsXmlContentValue value = m_xml . getValue ( path , m_locale ) ; if ( value == null ) { return null ; } else { return value . getStringValue ( null ) ; } } | Helper to read an optional String value . | 63 | 8 |
144,849 | protected List < String > parseOptionalStringValues ( final String path ) { final List < I_CmsXmlContentValue > values = m_xml . getValues ( path , m_locale ) ; if ( values == null ) { return null ; } else { List < String > stringValues = new ArrayList < String > ( values . size ( ) ) ; for ( I_CmsXmlContentValue value : values ) { stringValues . add ( value . getStringValue ( null ) ) ; } return stringValues ; } } | Helper to read an optional String value list . | 115 | 9 |
144,850 | protected I_CmsSearchConfigurationFacetRange parseRangeFacet ( String pathPrefix ) { try { final String range = parseMandatoryStringValue ( pathPrefix + XML_ELEMENT_RANGE_FACET_RANGE ) ; final String name = parseOptionalStringValue ( pathPrefix + XML_ELEMENT_FACET_NAME ) ; final String label = parseOptionalStringValue ( pathPrefix + XML_ELEMENT_FACET_LABEL ) ; final Integer minCount = parseOptionalIntValue ( pathPrefix + XML_ELEMENT_FACET_MINCOUNT ) ; final String start = parseMandatoryStringValue ( pathPrefix + XML_ELEMENT_RANGE_FACET_START ) ; final String end = parseMandatoryStringValue ( pathPrefix + XML_ELEMENT_RANGE_FACET_END ) ; final String gap = parseMandatoryStringValue ( pathPrefix + XML_ELEMENT_RANGE_FACET_GAP ) ; final String sother = parseOptionalStringValue ( pathPrefix + XML_ELEMENT_RANGE_FACET_OTHER ) ; List < I_CmsSearchConfigurationFacetRange . Other > other = null ; if ( sother != null ) { final List < String > sothers = Arrays . asList ( sother . split ( "," ) ) ; other = new ArrayList < I_CmsSearchConfigurationFacetRange . Other > ( sothers . size ( ) ) ; for ( String so : sothers ) { try { I_CmsSearchConfigurationFacetRange . Other o = I_CmsSearchConfigurationFacetRange . Other . valueOf ( so ) ; other . add ( o ) ; } catch ( final Exception e ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERR_INVALID_OTHER_OPTION_1 , so ) , e ) ; } } } final Boolean hardEnd = parseOptionalBooleanValue ( pathPrefix + XML_ELEMENT_RANGE_FACET_HARDEND ) ; final Boolean isAndFacet = parseOptionalBooleanValue ( pathPrefix + XML_ELEMENT_FACET_ISANDFACET ) ; final List < String > preselection = parseOptionalStringValues ( pathPrefix + XML_ELEMENT_FACET_PRESELECTION ) ; final Boolean ignoreAllFacetFilters = parseOptionalBooleanValue ( pathPrefix + XML_ELEMENT_FACET_IGNOREALLFACETFILTERS ) ; return new CmsSearchConfigurationFacetRange ( range , start , end , gap , other , hardEnd , name , minCount , label , isAndFacet , preselection , ignoreAllFacetFilters ) ; } catch ( final Exception e ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERR_RANGE_FACET_MANDATORY_KEY_MISSING_1 , XML_ELEMENT_RANGE_FACET_RANGE + ", " + XML_ELEMENT_RANGE_FACET_START + ", " + XML_ELEMENT_RANGE_FACET_END + ", " + XML_ELEMENT_RANGE_FACET_GAP ) , e ) ; return null ; } } | Reads the configuration of a range facet . | 756 | 9 |
144,851 | private List < Integer > getPageSizes ( ) { final String pageSizes = parseOptionalStringValue ( XML_ELEMENT_PAGESIZE ) ; if ( pageSizes != null ) { String [ ] pageSizesArray = pageSizes . split ( "-" ) ; if ( pageSizesArray . length > 0 ) { try { List < Integer > result = new ArrayList <> ( pageSizesArray . length ) ; for ( int i = 0 ; i < pageSizesArray . length ; i ++ ) { result . add ( Integer . valueOf ( pageSizesArray [ i ] ) ) ; } return result ; } catch ( NumberFormatException e ) { LOG . warn ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_PARSING_PAGE_SIZES_FAILED_1 , pageSizes ) , e ) ; } } } return null ; } | Returns the configured page size or the default page size if it is not configured . | 201 | 16 |
144,852 | private String getQueryParam ( ) { final String param = parseOptionalStringValue ( XML_ELEMENT_QUERYPARAM ) ; if ( param == null ) { return DEFAULT_QUERY_PARAM ; } else { return param ; } } | Returns the configured request parameter for the current query string or the default parameter if the core is not specified . | 54 | 21 |
144,853 | private List < I_CmsSearchConfigurationSortOption > getSortOptions ( ) { final List < I_CmsSearchConfigurationSortOption > options = new ArrayList < I_CmsSearchConfigurationSortOption > ( ) ; final CmsXmlContentValueSequence sortOptions = m_xml . getValueSequence ( XML_ELEMENT_SORTOPTIONS , m_locale ) ; if ( sortOptions == null ) { return null ; } else { for ( int i = 0 ; i < sortOptions . getElementCount ( ) ; i ++ ) { final I_CmsSearchConfigurationSortOption option = parseSortOption ( sortOptions . getValue ( i ) . getPath ( ) + "/" ) ; if ( option != null ) { options . add ( option ) ; } } return options ; } } | Returns the configured sort options or the empty list if no such options are configured . | 177 | 16 |
144,854 | private I_CmsFacetQueryItem parseFacetQueryItem ( final String prefix ) { I_CmsXmlContentValue query = m_xml . getValue ( prefix + XML_ELEMENT_QUERY_FACET_QUERY_QUERY , m_locale ) ; if ( null != query ) { String queryString = query . getStringValue ( null ) ; I_CmsXmlContentValue label = m_xml . getValue ( prefix + XML_ELEMENT_QUERY_FACET_QUERY_LABEL , m_locale ) ; String labelString = null != label ? label . getStringValue ( null ) : null ; return new CmsFacetQueryItem ( queryString , labelString ) ; } else { return null ; } } | Parses a single query facet item with query and label . | 171 | 13 |
144,855 | private String parseMandatoryStringValue ( final String path ) throws Exception { final String value = parseOptionalStringValue ( path ) ; if ( value == null ) { throw new Exception ( ) ; } return value ; } | Helper to read a mandatory String value . | 45 | 8 |
144,856 | protected I_CmsSearchDocument createDefaultIndexDocument ( ) { try { return m_index . getFieldConfiguration ( ) . createDocument ( m_cms , m_res , m_index , null ) ; } catch ( CmsException e ) { LOG . error ( "Default document for " + m_res . getRootPath ( ) + " and index " + m_index . getName ( ) + " could not be created." , e ) ; return null ; } } | Creates a document for the resource without extracting the content . The aim is to get a content indexed even if extraction runs into a timeout . | 103 | 28 |
144,857 | public CmsJspInstanceDateBean getToInstanceDate ( ) { if ( m_instanceDate == null ) { m_instanceDate = new CmsJspInstanceDateBean ( getToDate ( ) , m_cms . getRequestContext ( ) . getLocale ( ) ) ; } return m_instanceDate ; } | Converts a date to an instance date bean . | 72 | 10 |
144,858 | public static String getGalleryNotFoundKey ( String gallery ) { StringBuffer sb = new StringBuffer ( ERROR_REASON_NO_PREFIX ) ; sb . append ( gallery . toUpperCase ( ) ) ; sb . append ( GUI_TITLE_POSTFIX ) ; return sb . toString ( ) ; } | Convert gallery name to not found error key . | 73 | 10 |
144,859 | public static String getTitleGalleryKey ( String gallery ) { StringBuffer sb = new StringBuffer ( GUI_TITLE_PREFIX ) ; sb . append ( gallery . toUpperCase ( ) ) ; sb . append ( GUI_TITLE_POSTFIX ) ; return sb . toString ( ) ; } | Convert gallery name to title key . | 70 | 8 |
144,860 | public static String getTemplateMapperConfig ( ServletRequest request ) { String result = null ; CmsTemplateContext templateContext = ( CmsTemplateContext ) request . getAttribute ( CmsTemplateContextManager . ATTR_TEMPLATE_CONTEXT ) ; if ( templateContext != null ) { I_CmsTemplateContextProvider provider = templateContext . getProvider ( ) ; if ( provider instanceof I_CmsTemplateMappingContextProvider ) { result = ( ( I_CmsTemplateMappingContextProvider ) provider ) . getMappingConfigurationPath ( templateContext . getKey ( ) ) ; } } return result ; } | Checks if the selected template context is templatemapper . | 135 | 13 |
144,861 | private CmsTemplateMapperConfiguration getConfiguration ( final CmsObject cms ) { if ( ! m_enabled ) { return CmsTemplateMapperConfiguration . EMPTY_CONFIG ; } if ( m_configPath == null ) { m_configPath = OpenCms . getSystemInfo ( ) . getConfigFilePath ( cms , "template-mapping.xml" ) ; } return ( CmsTemplateMapperConfiguration ) ( CmsVfsMemoryObjectCache . getVfsMemoryObjectCache ( ) . loadVfsObject ( cms , m_configPath , new Transformer ( ) { @ Override public Object transform ( Object input ) { try { CmsFile file = cms . readFile ( m_configPath , CmsResourceFilter . IGNORE_EXPIRATION ) ; SAXReader saxBuilder = new SAXReader ( ) ; try ( ByteArrayInputStream stream = new ByteArrayInputStream ( file . getContents ( ) ) ) { Document document = saxBuilder . read ( stream ) ; CmsTemplateMapperConfiguration config = new CmsTemplateMapperConfiguration ( cms , document ) ; return config ; } } catch ( Exception e ) { LOG . warn ( e . getLocalizedMessage ( ) , e ) ; return new CmsTemplateMapperConfiguration ( ) ; // empty configuration, does not do anything } } } ) ) ; } | Loads the configuration file using CmsVfsMemoryObjectCache for caching . | 295 | 16 |
144,862 | private void onShow ( ) { if ( m_detailsFieldset != null ) { m_detailsFieldset . getContentPanel ( ) . getElement ( ) . getStyle ( ) . setPropertyPx ( "maxHeight" , getAvailableHeight ( m_messageWidget . getOffsetHeight ( ) ) ) ; } } | Checks the available space and sets max - height to the details field - set . | 69 | 17 |
144,863 | public void addModuleToExport ( final String moduleName ) { if ( m_modulesToExport == null ) { m_modulesToExport = new HashSet < String > ( ) ; } m_modulesToExport . add ( moduleName ) ; } | Adds a module to the modules that should be exported . If called at least once the explicitly added modules will be exported instead of the default modules . | 53 | 29 |
144,864 | public int checkIn ( ) { try { synchronized ( STATIC_LOCK ) { m_logStream = new PrintStream ( new FileOutputStream ( DEFAULT_LOGFILE_PATH , false ) ) ; CmsObject cms = getCmsObject ( ) ; if ( cms != null ) { return checkInInternal ( ) ; } else { m_logStream . println ( "No CmsObject given. Did you call init() first?" ) ; return - 1 ; } } } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; return - 2 ; } } | Start export and check in of the selected modules . | 128 | 10 |
144,865 | public boolean setCurrentConfiguration ( CmsGitConfiguration configuration ) { if ( ( null != configuration ) && configuration . isValid ( ) ) { m_currentConfiguration = configuration ; return true ; } return false ; } | Sets the current configuration if it is a valid configuration . Otherwise the configuration is not set . | 45 | 19 |
144,866 | private int checkInInternal ( ) { m_logStream . println ( "[" + new Date ( ) + "] STARTING Git task" ) ; m_logStream . println ( "=========================" ) ; m_logStream . println ( ) ; if ( m_checkout ) { m_logStream . println ( "Running checkout script" ) ; } else if ( ! ( m_resetHead || m_resetRemoteHead ) ) { m_logStream . println ( "Exporting relevant modules" ) ; m_logStream . println ( "--------------------------" ) ; m_logStream . println ( ) ; exportModules ( ) ; m_logStream . println ( ) ; m_logStream . println ( "Calling script to check in the exports" ) ; m_logStream . println ( "--------------------------------------" ) ; m_logStream . println ( ) ; } else { m_logStream . println ( ) ; m_logStream . println ( "Calling script to reset the repository" ) ; m_logStream . println ( "--------------------------------------" ) ; m_logStream . println ( ) ; } int exitCode = runCommitScript ( ) ; if ( exitCode != 0 ) { m_logStream . println ( ) ; m_logStream . println ( "ERROR: Something went wrong. The script got exitcode " + exitCode + "." ) ; m_logStream . println ( ) ; } if ( ( exitCode == 0 ) && m_checkout ) { boolean importOk = importModules ( ) ; if ( ! importOk ) { return - 1 ; } } m_logStream . println ( "[" + new Date ( ) + "] FINISHED Git task" ) ; m_logStream . println ( ) ; m_logStream . close ( ) ; return exitCode ; } | Export modules and check them in . Assumes the log stream already open . | 391 | 15 |
144,867 | private String checkinScriptCommand ( ) { String exportModules = "" ; if ( ( m_modulesToExport != null ) && ! m_modulesToExport . isEmpty ( ) ) { StringBuffer exportModulesParam = new StringBuffer ( ) ; for ( String moduleName : m_modulesToExport ) { exportModulesParam . append ( " " ) . append ( moduleName ) ; } exportModulesParam . replace ( 0 , 1 , " \"" ) ; exportModulesParam . append ( "\" " ) ; exportModules = " --modules " + exportModulesParam . toString ( ) ; } String commitMessage = "" ; if ( m_commitMessage != null ) { commitMessage = " -msg \"" + m_commitMessage . replace ( "\"" , "\\\"" ) + "\"" ; } String gitUserName = "" ; if ( m_gitUserName != null ) { if ( m_gitUserName . trim ( ) . isEmpty ( ) ) { gitUserName = " --ignore-default-git-user-name" ; } else { gitUserName = " --git-user-name \"" + m_gitUserName + "\"" ; } } String gitUserEmail = "" ; if ( m_gitUserEmail != null ) { if ( m_gitUserEmail . trim ( ) . isEmpty ( ) ) { gitUserEmail = " --ignore-default-git-user-email" ; } else { gitUserEmail = " --git-user-email \"" + m_gitUserEmail + "\"" ; } } String autoPullBefore = "" ; if ( m_autoPullBefore != null ) { autoPullBefore = m_autoPullBefore . booleanValue ( ) ? " --pull-before " : " --no-pull-before" ; } String autoPullAfter = "" ; if ( m_autoPullAfter != null ) { autoPullAfter = m_autoPullAfter . booleanValue ( ) ? " --pull-after " : " --no-pull-after" ; } String autoPush = "" ; if ( m_autoPush != null ) { autoPush = m_autoPush . booleanValue ( ) ? " --push " : " --no-push" ; } String exportFolder = " --export-folder \"" + m_currentConfiguration . getModuleExportPath ( ) + "\"" ; String exportMode = " --export-mode " + m_currentConfiguration . getExportMode ( ) ; String excludeLibs = "" ; if ( m_excludeLibs != null ) { excludeLibs = m_excludeLibs . booleanValue ( ) ? " --exclude-libs" : " --no-exclude-libs" ; } String commitMode = "" ; if ( m_commitMode != null ) { commitMode = m_commitMode . booleanValue ( ) ? " --commit" : " --no-commit" ; } String ignoreUncleanMode = "" ; if ( m_ignoreUnclean != null ) { ignoreUncleanMode = m_ignoreUnclean . booleanValue ( ) ? " --ignore-unclean" : " --no-ignore-unclean" ; } String copyAndUnzip = "" ; if ( m_copyAndUnzip != null ) { copyAndUnzip = m_copyAndUnzip . booleanValue ( ) ? " --copy-and-unzip" : " --no-copy-and-unzip" ; } String configFilePath = m_currentConfiguration . getFilePath ( ) ; return "\"" + DEFAULT_SCRIPT_FILE + "\"" + exportModules + commitMessage + gitUserName + gitUserEmail + autoPullBefore + autoPullAfter + autoPush + exportFolder + exportMode + excludeLibs + commitMode + ignoreUncleanMode + copyAndUnzip + " \"" + configFilePath + "\"" ; } | Returns the command to run by the shell to normally run the checkin script . | 843 | 16 |
144,868 | private void exportModules ( ) { // avoid to export modules if unnecessary if ( ( ( null != m_copyAndUnzip ) && ! m_copyAndUnzip . booleanValue ( ) ) || ( ( null == m_copyAndUnzip ) && ! m_currentConfiguration . getDefaultCopyAndUnzip ( ) ) ) { m_logStream . println ( ) ; m_logStream . println ( "NOT EXPORTING MODULES - you disabled copy and unzip." ) ; m_logStream . println ( ) ; return ; } CmsModuleManager moduleManager = OpenCms . getModuleManager ( ) ; Collection < String > modulesToExport = ( ( m_modulesToExport == null ) || m_modulesToExport . isEmpty ( ) ) ? m_currentConfiguration . getConfiguredModules ( ) : m_modulesToExport ; for ( String moduleName : modulesToExport ) { CmsModule module = moduleManager . getModule ( moduleName ) ; if ( module != null ) { CmsModuleImportExportHandler handler = CmsModuleImportExportHandler . getExportHandler ( getCmsObject ( ) , module , "Git export handler" ) ; try { handler . exportData ( getCmsObject ( ) , new CmsPrintStreamReport ( m_logStream , OpenCms . getWorkplaceManager ( ) . getWorkplaceLocale ( getCmsObject ( ) ) , false ) ) ; } catch ( CmsRoleViolationException | CmsConfigurationException | CmsImportExportException e ) { e . printStackTrace ( m_logStream ) ; } } } } | Export the modules that should be checked in into git . | 349 | 11 |
144,869 | private List < CmsGitConfiguration > readConfigFiles ( ) { List < CmsGitConfiguration > configurations = new LinkedList < CmsGitConfiguration > ( ) ; // Default configuration file for backwards compatibility addConfigurationIfValid ( configurations , new File ( DEFAULT_CONFIG_FILE ) ) ; // All files in the config folder File configFolder = new File ( DEFAULT_CONFIG_FOLDER ) ; if ( configFolder . isDirectory ( ) ) { for ( File configFile : configFolder . listFiles ( ) ) { addConfigurationIfValid ( configurations , configFile ) ; } } return configurations ; } | Read all configuration files . | 134 | 5 |
144,870 | private int runCommitScript ( ) { if ( m_checkout && ! m_fetchAndResetBeforeImport ) { m_logStream . println ( "Skipping script...." ) ; return 0 ; } try { m_logStream . flush ( ) ; String commandParam ; if ( m_resetRemoteHead ) { commandParam = resetRemoteHeadScriptCommand ( ) ; } else if ( m_resetHead ) { commandParam = resetHeadScriptCommand ( ) ; } else if ( m_checkout ) { commandParam = checkoutScriptCommand ( ) ; } else { commandParam = checkinScriptCommand ( ) ; } String [ ] cmd = { "bash" , "-c" , commandParam } ; m_logStream . println ( "Calling the script as follows:" ) ; m_logStream . println ( ) ; m_logStream . println ( cmd [ 0 ] + " " + cmd [ 1 ] + " " + cmd [ 2 ] ) ; ProcessBuilder builder = new ProcessBuilder ( cmd ) ; m_logStream . close ( ) ; m_logStream = null ; Redirect redirect = Redirect . appendTo ( new File ( DEFAULT_LOGFILE_PATH ) ) ; builder . redirectOutput ( redirect ) ; builder . redirectError ( redirect ) ; Process scriptProcess = builder . start ( ) ; int exitCode = scriptProcess . waitFor ( ) ; scriptProcess . getOutputStream ( ) . close ( ) ; m_logStream = new PrintStream ( new FileOutputStream ( DEFAULT_LOGFILE_PATH , true ) ) ; return exitCode ; } catch ( InterruptedException | IOException e ) { e . printStackTrace ( m_logStream ) ; return - 1 ; } } | Runs the shell script for committing and optionally pushing the changes in the module . | 370 | 16 |
144,871 | protected void updateForNewConfiguration ( CmsGitConfiguration gitConfig ) { if ( ! m_checkinBean . setCurrentConfiguration ( gitConfig ) ) { Notification . show ( CmsVaadinUtils . getMessageText ( Messages . GUI_GIT_CONFIGURATION_SWITCH_FAILED_0 ) , CmsVaadinUtils . getMessageText ( Messages . GUI_GIT_CONFIGURATION_SWITCH_FAILED_DESC_0 ) , Type . ERROR_MESSAGE ) ; m_configurationSelector . select ( m_checkinBean . getCurrentConfiguration ( ) ) ; return ; } resetSelectableModules ( ) ; for ( final String moduleName : gitConfig . getConfiguredModules ( ) ) { addSelectableModule ( moduleName ) ; } updateNewModuleSelector ( ) ; m_pullFirst . setValue ( Boolean . valueOf ( gitConfig . getDefaultAutoPullBefore ( ) ) ) ; m_pullAfterCommit . setValue ( Boolean . valueOf ( gitConfig . getDefaultAutoPullAfter ( ) ) ) ; m_addAndCommit . setValue ( Boolean . valueOf ( gitConfig . getDefaultAutoCommit ( ) ) ) ; m_pushAutomatically . setValue ( Boolean . valueOf ( gitConfig . getDefaultAutoPush ( ) ) ) ; m_commitMessage . setValue ( Strings . nullToEmpty ( gitConfig . getDefaultCommitMessage ( ) ) ) ; m_copyAndUnzip . setValue ( Boolean . valueOf ( gitConfig . getDefaultCopyAndUnzip ( ) ) ) ; m_excludeLib . setValue ( Boolean . valueOf ( gitConfig . getDefaultExcludeLibs ( ) ) ) ; m_ignoreUnclean . setValue ( Boolean . valueOf ( gitConfig . getDefaultIngoreUnclean ( ) ) ) ; m_userField . setValue ( Strings . nullToEmpty ( gitConfig . getDefaultGitUserName ( ) ) ) ; m_emailField . setValue ( Strings . nullToEmpty ( gitConfig . getDefaultGitUserEmail ( ) ) ) ; } | Updates the options panel for a special configuration . | 469 | 10 |
144,872 | private void configureConfigurationSelector ( ) { if ( m_checkinBean . getConfigurations ( ) . size ( ) < 2 ) { // Do not show the configuration selection at all. removeComponent ( m_configurationSelectionPanel ) ; } else { for ( CmsGitConfiguration configuration : m_checkinBean . getConfigurations ( ) ) { m_configurationSelector . addItem ( configuration ) ; m_configurationSelector . setItemCaption ( configuration , configuration . getName ( ) ) ; } m_configurationSelector . setNullSelectionAllowed ( false ) ; m_configurationSelector . setNewItemsAllowed ( false ) ; m_configurationSelector . setWidth ( "350px" ) ; m_configurationSelector . select ( m_checkinBean . getCurrentConfiguration ( ) ) ; // There is really a choice between configurations m_configurationSelector . addValueChangeListener ( new ValueChangeListener ( ) { private static final long serialVersionUID = 1L ; @ SuppressWarnings ( "synthetic-access" ) public void valueChange ( ValueChangeEvent event ) { updateForNewConfiguration ( ( CmsGitConfiguration ) event . getProperty ( ) . getValue ( ) ) ; restoreFieldsFromUserInfo ( ) ; } } ) ; } } | Configures the configuration selector . | 291 | 6 |
144,873 | public void loadWithTimeout ( int timeout ) { for ( String stylesheet : m_stylesheets ) { boolean alreadyLoaded = checkStylesheet ( stylesheet ) ; if ( alreadyLoaded ) { m_loadCounter += 1 ; } else { appendStylesheet ( stylesheet , m_jsCallback ) ; } } checkAllLoaded ( ) ; if ( timeout > 0 ) { Timer timer = new Timer ( ) { @ SuppressWarnings ( "synthetic-access" ) @ Override public void run ( ) { callCallback ( ) ; } } ; timer . schedule ( timeout ) ; } } | Starts the loading process and creates a timer that sets of the callback after a given tiime if it hasn t already been triggered . | 135 | 27 |
144,874 | protected boolean hasPermissions ( CmsObject cms , CmsSolrDocument doc , CmsResourceFilter filter ) { return null != ( filter == null ? getResource ( cms , doc ) : getResource ( cms , doc , filter ) ) ; } | Check if the current user has permissions on the document s resource . | 56 | 13 |
144,875 | private boolean isDebug ( CmsObject cms , CmsSolrQuery query ) { String [ ] debugSecretValues = query . remove ( REQUEST_PARAM_DEBUG_SECRET ) ; String debugSecret = ( debugSecretValues == null ) || ( debugSecretValues . length < 1 ) ? null : debugSecretValues [ 0 ] ; if ( ( null != debugSecret ) && ! debugSecret . trim ( ) . isEmpty ( ) && ( null != m_handlerDebugSecretFile ) ) { try { CmsFile secretFile = cms . readFile ( m_handlerDebugSecretFile ) ; String secret = new String ( secretFile . getContents ( ) , CmsFileUtil . getEncoding ( cms , secretFile ) ) ; return secret . trim ( ) . equals ( debugSecret . trim ( ) ) ; } catch ( Exception e ) { LOG . info ( "Failed to read secret file for index \"" + getName ( ) + "\" at path \"" + m_handlerDebugSecretFile + "\"." ) ; } } return false ; } | Checks if the query should be executed using the debug mode where the security restrictions do not apply . | 231 | 20 |
144,876 | private void throwExceptionIfSafetyRestrictionsAreViolated ( CmsObject cms , CmsSolrQuery query , boolean isSpell ) throws CmsSearchException { if ( ! isDebug ( cms , query ) ) { if ( isSpell ) { if ( m_handlerSpellDisabled ) { throw new CmsSearchException ( Messages . get ( ) . container ( Messages . GUI_HANDLER_REQUEST_NOT_ALLOWED_0 ) ) ; } } else { if ( m_handlerSelectDisabled ) { throw new CmsSearchException ( Messages . get ( ) . container ( Messages . GUI_HANDLER_REQUEST_NOT_ALLOWED_0 ) ) ; } int start = null != query . getStart ( ) ? query . getStart ( ) . intValue ( ) : 0 ; int rows = null != query . getRows ( ) ? query . getRows ( ) . intValue ( ) : CmsSolrQuery . DEFAULT_ROWS . intValue ( ) ; if ( ( m_handlerMaxAllowedResultsAtAll >= 0 ) && ( ( rows + start ) > m_handlerMaxAllowedResultsAtAll ) ) { throw new CmsSearchException ( Messages . get ( ) . container ( Messages . GUI_HANDLER_TOO_MANY_RESULTS_REQUESTED_AT_ALL_2 , Integer . valueOf ( m_handlerMaxAllowedResultsAtAll ) , Integer . valueOf ( rows + start ) ) ) ; } if ( ( m_handlerMaxAllowedResultsPerPage >= 0 ) && ( rows > m_handlerMaxAllowedResultsPerPage ) ) { throw new CmsSearchException ( Messages . get ( ) . container ( Messages . GUI_HANDLER_TOO_MANY_RESULTS_REQUESTED_PER_PAGE_2 , Integer . valueOf ( m_handlerMaxAllowedResultsPerPage ) , Integer . valueOf ( rows ) ) ) ; } if ( ( null != m_handlerAllowedFields ) && ( Stream . of ( m_handlerAllowedFields ) . anyMatch ( x -> true ) ) ) { if ( query . getFields ( ) . equals ( CmsSolrQuery . ALL_RETURN_FIELDS ) ) { query . setFields ( m_handlerAllowedFields ) ; } else { for ( String requestedField : query . getFields ( ) . split ( "," ) ) { if ( Stream . of ( m_handlerAllowedFields ) . noneMatch ( allowedField -> allowedField . equals ( requestedField ) ) ) { throw new CmsSearchException ( Messages . get ( ) . container ( Messages . GUI_HANDLER_REQUESTED_FIELD_NOT_ALLOWED_2 , requestedField , Stream . of ( m_handlerAllowedFields ) . reduce ( "" , ( a , b ) -> a + "," + b ) ) ) ; } } } } } } } | Throws an exception if the request can for security reasons not be performed . Security restrictions can be set via parameters of the index . | 644 | 26 |
144,877 | private String alterPrefix ( String word , String oldPrefix , String newPrefix ) { if ( word . startsWith ( oldPrefix ) ) { return word . replaceFirst ( oldPrefix , newPrefix ) ; } return ( newPrefix + word ) ; } | Manipulates a string by cutting of a prefix if present and adding a new prefix . | 59 | 18 |
144,878 | public void updateColor ( TestColor color ) { switch ( color ) { case green : m_forwardButton . setEnabled ( true ) ; m_confirmCheckbox . setVisible ( false ) ; m_status . setValue ( STATUS_GREEN ) ; break ; case yellow : m_forwardButton . setEnabled ( false ) ; m_confirmCheckbox . setVisible ( true ) ; m_status . setValue ( STATUS_YELLOW ) ; break ; case red : m_forwardButton . setEnabled ( false ) ; m_confirmCheckbox . setVisible ( true ) ; m_status . setValue ( STATUS_RED ) ; break ; default : break ; } } | Sets test status . | 152 | 5 |
144,879 | public void copyCategories ( CmsObject cms , CmsResource fromResource , String toResourceSitePath ) throws CmsException { List < CmsCategory > categories = readResourceCategories ( cms , fromResource ) ; for ( CmsCategory category : categories ) { addResourceToCategory ( cms , toResourceSitePath , category ) ; } } | Adds all categories from one resource to another skipping categories that are not available for the resource copied to . | 77 | 20 |
144,880 | static Locale getLocale ( PageContext pageContext , String name ) { Locale loc = null ; Object obj = javax . servlet . jsp . jstl . core . Config . find ( pageContext , name ) ; if ( obj != null ) { if ( obj instanceof Locale ) { loc = ( Locale ) obj ; } else { loc = SetLocaleSupport . parseLocale ( ( String ) obj ) ; } } return loc ; } | Returns the locale specified by the named scoped attribute or context configuration parameter . | 101 | 15 |
144,881 | protected String generateCacheKey ( CmsObject cms , String targetSiteRoot , String detailPagePart , String absoluteLink ) { return cms . getRequestContext ( ) . getSiteRoot ( ) + ":" + targetSiteRoot + ":" + detailPagePart + absoluteLink ; } | Generates the cache key for Online links . | 61 | 9 |
144,882 | protected boolean isSecureLink ( CmsObject cms , String vfsName , CmsSite targetSite , boolean secureRequest ) { return OpenCms . getStaticExportManager ( ) . isSecureLink ( cms , vfsName , targetSite . getSiteRoot ( ) , secureRequest ) ; } | Checks if the link target is a secure link . <p | 65 | 13 |
144,883 | private float MIN ( float first , float second , float third ) { float min = Integer . MAX_VALUE ; if ( first < min ) { min = first ; } if ( second < min ) { min = second ; } if ( third < min ) { min = third ; } return min ; } | Calculates the smallest value between the three inputs . | 63 | 11 |
144,884 | private void setHex ( ) { String hRed = Integer . toHexString ( getRed ( ) ) ; String hGreen = Integer . toHexString ( getGreen ( ) ) ; String hBlue = Integer . toHexString ( getBlue ( ) ) ; if ( hRed . length ( ) == 0 ) { hRed = "00" ; } if ( hRed . length ( ) == 1 ) { hRed = "0" + hRed ; } if ( hGreen . length ( ) == 0 ) { hGreen = "00" ; } if ( hGreen . length ( ) == 1 ) { hGreen = "0" + hGreen ; } if ( hBlue . length ( ) == 0 ) { hBlue = "00" ; } if ( hBlue . length ( ) == 1 ) { hBlue = "0" + hBlue ; } m_hex = hRed + hGreen + hBlue ; } | Converts from RGB to Hexadecimal notation . | 202 | 11 |
144,885 | private String formatDate ( Date date ) { if ( null == m_dateFormat ) { m_dateFormat = DateFormat . getDateInstance ( 0 , OpenCms . getWorkplaceManager ( ) . getWorkplaceLocale ( getCmsObject ( ) ) ) ; } return m_dateFormat . format ( date ) ; } | Format the date for the status messages . | 72 | 8 |
144,886 | public static String createResource ( CmsObject cmsObject , String newLink , Locale locale , String sitePath , String modelFileName , String mode , String postCreateHandler ) { String [ ] newLinkParts = newLink . split ( "\\|" ) ; String rootPath = newLinkParts [ 1 ] ; String typeName = newLinkParts [ 2 ] ; CmsFile modelFile = null ; if ( StringUtils . equalsIgnoreCase ( mode , CmsEditorConstants . MODE_COPY ) ) { try { modelFile = cmsObject . readFile ( sitePath ) ; } catch ( CmsException e ) { LOG . warn ( "The resource at path" + sitePath + "could not be read. Thus it can not be used as model file." , e ) ; } } CmsADEConfigData adeConfig = OpenCms . getADEManager ( ) . lookupConfiguration ( cmsObject , rootPath ) ; CmsResourceTypeConfig typeConfig = adeConfig . getResourceType ( typeName ) ; CmsResource newElement = null ; try { CmsObject cmsClone = cmsObject ; if ( ( locale != null ) && ! cmsObject . getRequestContext ( ) . getLocale ( ) . equals ( locale ) ) { // in case the content locale does not match the request context locale, use a clone cms with the appropriate locale cmsClone = OpenCms . initCmsObject ( cmsObject ) ; cmsClone . getRequestContext ( ) . setLocale ( locale ) ; } newElement = typeConfig . createNewElement ( cmsClone , modelFile , rootPath ) ; CmsPair < String , String > handlerParameter = I_CmsCollectorPostCreateHandler . splitClassAndConfig ( postCreateHandler ) ; I_CmsCollectorPostCreateHandler handler = A_CmsResourceCollector . getPostCreateHandler ( handlerParameter . getFirst ( ) ) ; handler . onCreate ( cmsClone , cmsClone . readFile ( newElement ) , modelFile != null , handlerParameter . getSecond ( ) ) ; } catch ( CmsException e ) { LOG . error ( "Could not create resource." , e ) ; } return newElement == null ? null : cmsObject . getSitePath ( newElement ) ; } | Creates a new resource . | 512 | 6 |
144,887 | private static I_CmsResourceBundle tryBundle ( String localizedName ) { I_CmsResourceBundle result = null ; try { String resourceName = localizedName . replace ( ' ' , ' ' ) + ".properties" ; URL url = CmsResourceBundleLoader . class . getClassLoader ( ) . getResource ( resourceName ) ; I_CmsResourceBundle additionalBundle = m_permanentCache . get ( localizedName ) ; if ( additionalBundle != null ) { result = additionalBundle . getClone ( ) ; } else if ( url != null ) { // the resource was found on the file system InputStream is = null ; String path = CmsFileUtil . normalizePath ( url ) ; File file = new File ( path ) ; try { // try to load the resource bundle from a file, NOT with the resource loader first // this is important since using #getResourceAsStream() may return cached results, // for example Tomcat by default does cache all resources loaded by the class loader // this means a changed resource bundle file is not loaded is = new FileInputStream ( file ) ; } catch ( IOException ex ) { // this will happen if the resource is contained for example in a .jar file is = CmsResourceBundleLoader . class . getClassLoader ( ) . getResourceAsStream ( resourceName ) ; } catch ( AccessControlException acex ) { // fixed bug #1550 // this will happen if the resource is contained for example in a .jar file // and security manager is turned on. is = CmsResourceBundleLoader . class . getClassLoader ( ) . getResourceAsStream ( resourceName ) ; } if ( is != null ) { result = new CmsPropertyResourceBundle ( is ) ; } } } catch ( IOException ex ) { // can't localized these message since this may lead to a chicken-egg problem MissingResourceException mre = new MissingResourceException ( "Failed to load bundle '" + localizedName + "'" , localizedName , "" ) ; mre . initCause ( ex ) ; throw mre ; } return result ; } | Tries to load a property file with the specified name . | 455 | 12 |
144,888 | private static ResourceBundle tryBundle ( String baseName , Locale locale , boolean wantBase ) { I_CmsResourceBundle first = null ; // The most specialized bundle. I_CmsResourceBundle last = null ; // The least specialized bundle. List < String > bundleNames = CmsLocaleManager . getLocaleVariants ( baseName , locale , true , true ) ; for ( String bundleName : bundleNames ) { // break if we would try the base bundle, but we do not want it directly if ( bundleName . equals ( baseName ) && ! wantBase && ( first == null ) ) { break ; } I_CmsResourceBundle foundBundle = tryBundle ( bundleName ) ; if ( foundBundle != null ) { if ( first == null ) { first = foundBundle ; } if ( last != null ) { last . setParent ( ( ResourceBundle ) foundBundle ) ; } foundBundle . setLocale ( locale ) ; last = foundBundle ; } } return ( ResourceBundle ) first ; } | Tries to load a the bundle for a given locale also loads the backup locales with the same language . | 230 | 22 |
144,889 | public CmsMessageContainer validateWithMessage ( ) { if ( m_parsingFailed ) { return Messages . get ( ) . container ( Messages . ERR_SERIALDATE_INVALID_VALUE_0 ) ; } if ( ! isStartSet ( ) ) { return Messages . get ( ) . container ( Messages . ERR_SERIALDATE_START_MISSING_0 ) ; } if ( ! isEndValid ( ) ) { return Messages . get ( ) . container ( Messages . ERR_SERIALDATE_END_BEFORE_START_0 ) ; } String key = validatePattern ( ) ; if ( null != key ) { return Messages . get ( ) . container ( key ) ; } key = validateDuration ( ) ; if ( null != key ) { return Messages . get ( ) . container ( key ) ; } if ( hasTooManyEvents ( ) ) { return Messages . get ( ) . container ( Messages . ERR_SERIALDATE_TOO_MANY_EVENTS_1 , Integer . valueOf ( CmsSerialDateUtil . getMaxEvents ( ) ) ) ; } return null ; } | Validates the wrapped value and returns a localized error message in case of invalid values . | 252 | 17 |
144,890 | private JSONArray datesToJson ( Collection < Date > individualDates ) { if ( null != individualDates ) { JSONArray result = new JSONArray ( ) ; for ( Date d : individualDates ) { result . put ( dateToJson ( d ) ) ; } return result ; } return null ; } | Converts a list of dates to a Json array with the long representation of the dates as strings . | 68 | 21 |
144,891 | private JSONArray readOptionalArray ( JSONObject json , String key ) { try { return json . getJSONArray ( key ) ; } catch ( JSONException e ) { LOG . debug ( "Reading optional JSON array failed. Default to provided default value." , e ) ; } return null ; } | Read an optional JSON array . | 61 | 6 |
144,892 | private Boolean readOptionalBoolean ( JSONObject json , String key ) { try { return Boolean . valueOf ( json . getBoolean ( key ) ) ; } catch ( JSONException e ) { LOG . debug ( "Reading optional JSON boolean failed. Default to provided default value." , e ) ; } return null ; } | Read an optional boolean value form a JSON Object . | 67 | 10 |
144,893 | private String readOptionalString ( JSONObject json , String key , String defaultValue ) { try { String str = json . getString ( key ) ; if ( str != null ) { return str ; } } catch ( JSONException e ) { LOG . debug ( "Reading optional JSON string failed. Default to provided default value." , e ) ; } return defaultValue ; } | Read an optional string value form a JSON Object . | 77 | 10 |
144,894 | private void readPattern ( JSONObject patternJson ) { setPatternType ( readPatternType ( patternJson ) ) ; setInterval ( readOptionalInt ( patternJson , JsonKey . PATTERN_INTERVAL ) ) ; setWeekDays ( readWeekDays ( patternJson ) ) ; setDayOfMonth ( readOptionalInt ( patternJson , JsonKey . PATTERN_DAY_OF_MONTH ) ) ; setEveryWorkingDay ( readOptionalBoolean ( patternJson , JsonKey . PATTERN_EVERYWORKINGDAY ) ) ; setWeeksOfMonth ( readWeeksOfMonth ( patternJson ) ) ; setIndividualDates ( readDates ( readOptionalArray ( patternJson , JsonKey . PATTERN_DATES ) ) ) ; setMonth ( readOptionalMonth ( patternJson , JsonKey . PATTERN_MONTH ) ) ; } | Read pattern information from the provided JSON object . | 195 | 9 |
144,895 | private JSONArray toJsonStringArray ( Collection < ? extends Object > collection ) { if ( null != collection ) { JSONArray array = new JSONArray ( ) ; for ( Object o : collection ) { array . put ( "" + o ) ; } return array ; } else { return null ; } } | Convert a collection of objects to a JSON array with the string representations of that objects . | 64 | 18 |
144,896 | private String validateDuration ( ) { if ( ! isValidEndTypeForPattern ( ) ) { return Messages . ERR_SERIALDATE_INVALID_END_TYPE_FOR_PATTERN_0 ; } switch ( getEndType ( ) ) { case DATE : return ( getStart ( ) . getTime ( ) < ( getSeriesEndDate ( ) . getTime ( ) + DAY_IN_MILLIS ) ) ? null : Messages . ERR_SERIALDATE_SERIES_END_BEFORE_START_0 ; case TIMES : return getOccurrences ( ) > 0 ? null : Messages . ERR_SERIALDATE_INVALID_OCCURRENCES_0 ; default : return null ; } } | Checks if the provided duration information is valid . | 166 | 10 |
144,897 | private String validatePattern ( ) { String error = null ; switch ( getPatternType ( ) ) { case DAILY : error = isEveryWorkingDay ( ) ? null : validateInterval ( ) ; break ; case WEEKLY : error = validateInterval ( ) ; if ( null == error ) { error = validateWeekDaySet ( ) ; } break ; case MONTHLY : error = validateInterval ( ) ; if ( null == error ) { error = validateMonthSet ( ) ; if ( null == error ) { error = isWeekDaySet ( ) ? validateWeekOfMonthSet ( ) : validateDayOfMonth ( ) ; } } break ; case YEARLY : error = isWeekDaySet ( ) ? validateWeekOfMonthSet ( ) : validateDayOfMonth ( ) ; break ; case INDIVIDUAL : case NONE : default : } return error ; } | Check if all values used for calculating the series for a specific pattern are valid . | 185 | 16 |
144,898 | public static HikariConfig createHikariConfig ( CmsParameterConfiguration config , String key ) { Map < String , String > poolMap = Maps . newHashMap ( ) ; for ( Map . Entry < String , String > entry : config . entrySet ( ) ) { String suffix = getPropertyRelativeSuffix ( KEY_DATABASE_POOL + "." + key , entry . getKey ( ) ) ; if ( ( suffix != null ) && ! CmsStringUtil . isEmptyOrWhitespaceOnly ( entry . getValue ( ) ) ) { String value = entry . getValue ( ) . trim ( ) ; poolMap . put ( suffix , value ) ; } } // these are for backwards compatibility , all other properties not of the form db.pool.poolname.v11..... are ignored String jdbcUrl = poolMap . get ( KEY_JDBC_URL ) ; String params = poolMap . get ( KEY_JDBC_URL_PARAMS ) ; String driver = poolMap . get ( KEY_JDBC_DRIVER ) ; String user = poolMap . get ( KEY_USERNAME ) ; String password = poolMap . get ( KEY_PASSWORD ) ; String poolName = OPENCMS_URL_PREFIX + key ; if ( ( params != null ) && ( jdbcUrl != null ) ) { jdbcUrl += params ; } Properties hikariProps = new Properties ( ) ; if ( jdbcUrl != null ) { hikariProps . put ( "jdbcUrl" , jdbcUrl ) ; } if ( driver != null ) { hikariProps . put ( "driverClassName" , driver ) ; } if ( user != null ) { user = OpenCms . getCredentialsResolver ( ) . resolveCredential ( I_CmsCredentialsResolver . DB_USER , user ) ; hikariProps . put ( "username" , user ) ; } if ( password != null ) { password = OpenCms . getCredentialsResolver ( ) . resolveCredential ( I_CmsCredentialsResolver . DB_PASSWORD , password ) ; hikariProps . put ( "password" , password ) ; } hikariProps . put ( "maximumPoolSize" , "30" ) ; // Properties of the form db.pool.poolname.v11.<foo> are directly passed to HikariCP as <foo> for ( Map . Entry < String , String > entry : poolMap . entrySet ( ) ) { String suffix = getPropertyRelativeSuffix ( "v11" , entry . getKey ( ) ) ; if ( suffix != null ) { hikariProps . put ( suffix , entry . getValue ( ) ) ; } } String configuredTestQuery = ( String ) ( hikariProps . get ( "connectionTestQuery" ) ) ; String testQueryForDriver = testQueries . get ( driver ) ; if ( ( testQueryForDriver != null ) && CmsStringUtil . isEmptyOrWhitespaceOnly ( configuredTestQuery ) ) { hikariProps . put ( "connectionTestQuery" , testQueryForDriver ) ; } hikariProps . put ( "registerMbeans" , "true" ) ; HikariConfig result = new HikariConfig ( hikariProps ) ; result . setPoolName ( poolName . replace ( ":" , "_" ) ) ; return result ; } | Creates the HikariCP configuration based on the configuration of a pool defined in opencms . properties . | 763 | 21 |
144,899 | private CmsXmlContent unmarshalXmlContent ( CmsFile file ) throws CmsXmlException { CmsXmlContent content = CmsXmlContentFactory . unmarshal ( m_cms , file ) ; content . setAutoCorrectionEnabled ( true ) ; content . correctXmlStructure ( m_cms ) ; return content ; } | Unmarshal the XML content with auto - correction . | 77 | 12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.