idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
21,500
private void fillToolBar ( final I_CmsAppUIContext context ) { context . setAppTitle ( m_messages . key ( Messages . GUI_APP_TITLE_0 ) ) ; Component publishBtn = createPublishButton ( ) ; m_saveBtn = createSaveButton ( ) ; m_saveExitBtn = createSaveExitButton ( ) ; Component closeBtn = createCloseButton ( ) ; context . enableDefaultToolbarButtons ( false ) ; context . addToolbarButtonRight ( closeBtn ) ; context . addToolbarButton ( publishBtn ) ; context . addToolbarButton ( m_saveExitBtn ) ; context . addToolbarButton ( m_saveBtn ) ; Component addDescriptorBtn = createAddDescriptorButton ( ) ; if ( m_model . hasDescriptor ( ) || m_model . getBundleType ( ) . equals ( BundleType . DESCRIPTOR ) ) { addDescriptorBtn . setEnabled ( false ) ; } context . addToolbarButton ( addDescriptorBtn ) ; if ( m_model . getBundleType ( ) . equals ( BundleType . XML ) ) { Component convertToPropertyBundleBtn = createConvertToPropertyBundleButton ( ) ; context . addToolbarButton ( convertToPropertyBundleBtn ) ; } }
Adds Editor specific UI components to the toolbar .
21,501
private void handleChange ( Object propertyId ) { if ( ! m_saveBtn . isEnabled ( ) ) { m_saveBtn . setEnabled ( true ) ; m_saveExitBtn . setEnabled ( true ) ; } m_model . handleChange ( propertyId ) ; }
Handle a value change .
21,502
private void initFieldFactories ( ) { if ( m_model . hasMasterMode ( ) ) { TranslateTableFieldFactory masterFieldFactory = new CmsMessageBundleEditorTypes . TranslateTableFieldFactory ( m_table , m_model . getEditableColumns ( CmsMessageBundleEditorTypes . EditMode . MASTER ) ) ; masterFieldFactory . registerKeyChangeListener ( this ) ; m_fieldFactories . put ( CmsMessageBundleEditorTypes . EditMode . MASTER , masterFieldFactory ) ; } TranslateTableFieldFactory defaultFieldFactory = new CmsMessageBundleEditorTypes . TranslateTableFieldFactory ( m_table , m_model . getEditableColumns ( CmsMessageBundleEditorTypes . EditMode . DEFAULT ) ) ; defaultFieldFactory . registerKeyChangeListener ( this ) ; m_fieldFactories . put ( CmsMessageBundleEditorTypes . EditMode . DEFAULT , defaultFieldFactory ) ; }
Initialize the field factories for the messages table .
21,503
private void initStyleGenerators ( ) { if ( m_model . hasMasterMode ( ) ) { m_styleGenerators . put ( CmsMessageBundleEditorTypes . EditMode . MASTER , new CmsMessageBundleEditorTypes . TranslateTableCellStyleGenerator ( m_model . getEditableColumns ( CmsMessageBundleEditorTypes . EditMode . MASTER ) ) ) ; } m_styleGenerators . put ( CmsMessageBundleEditorTypes . EditMode . DEFAULT , new CmsMessageBundleEditorTypes . TranslateTableCellStyleGenerator ( m_model . getEditableColumns ( CmsMessageBundleEditorTypes . EditMode . DEFAULT ) ) ) ; }
Initialize the style generators for the messages table .
21,504
private boolean keyAlreadyExists ( String newKey ) { Collection < ? > itemIds = m_table . getItemIds ( ) ; for ( Object itemId : itemIds ) { if ( m_table . getItem ( itemId ) . getItemProperty ( TableProperty . KEY ) . getValue ( ) . equals ( newKey ) ) { return true ; } } return false ; }
Checks if a key already exists .
21,505
public void uploadFields ( final Set < String > fields , final Function < Map < String , String > , Void > filenameCallback , final I_CmsErrorCallback errorCallback ) { disableAllFileFieldsExcept ( fields ) ; final String id = CmsJsUtils . generateRandomId ( ) ; updateFormAction ( id ) ; final HandlerRegistration [ ] registration = { null } ; registration [ 0 ] = addSubmitCompleteHandler ( new SubmitCompleteHandler ( ) { @ SuppressWarnings ( "synthetic-access" ) public void onSubmitComplete ( SubmitCompleteEvent event ) { enableAllFileFields ( ) ; registration [ 0 ] . removeHandler ( ) ; CmsUUID sessionId = m_formSession . internalGetSessionId ( ) ; RequestBuilder requestBuilder = CmsXmlContentUgcApi . SERVICE . uploadFiles ( sessionId , fields , id , new AsyncCallback < Map < String , String > > ( ) { public void onFailure ( Throwable caught ) { m_formSession . getContentFormApi ( ) . handleError ( caught , errorCallback ) ; } public void onSuccess ( Map < String , String > fileNames ) { filenameCallback . apply ( fileNames ) ; } } ) ; m_formSession . getContentFormApi ( ) . getRpcHelper ( ) . executeRpc ( requestBuilder ) ; m_formSession . getContentFormApi ( ) . getRequestCounter ( ) . decrement ( ) ; } } ) ; m_formSession . getContentFormApi ( ) . getRequestCounter ( ) . increment ( ) ; submit ( ) ; }
Uploads files from the given file input fields . <p<
21,506
public static CmsJspResourceWrapper convertResource ( CmsObject cms , Object input ) throws CmsException { CmsJspResourceWrapper result ; if ( input instanceof CmsResource ) { result = CmsJspResourceWrapper . wrap ( cms , ( CmsResource ) input ) ; } else { result = CmsJspResourceWrapper . wrap ( cms , convertRawResource ( cms , input ) ) ; } return result ; }
Returns a resource wrapper created from the input .
21,507
public static List < CmsJspResourceWrapper > convertResourceList ( CmsObject cms , List < CmsResource > list ) { List < CmsJspResourceWrapper > result = new ArrayList < CmsJspResourceWrapper > ( list . size ( ) ) ; for ( CmsResource res : list ) { result . add ( CmsJspResourceWrapper . wrap ( cms , res ) ) ; } return result ; }
Returns a list of resource wrappers created from the input list of resources .
21,508
public static I_CmsSearchConfigurationPagination create ( String pageParam , List < Integer > pageSizes , Integer pageNavLength ) { return ( pageParam != null ) || ( pageSizes != null ) || ( pageNavLength != null ) ? new CmsSearchConfigurationPagination ( pageParam , pageSizes , pageNavLength ) : null ; }
Creates a new pagination configuration if at least one of the provided parameters is not null . Otherwise returns null .
21,509
public static String getDateCreatedTimeRangeFilterQuery ( String searchField , long startTime , long endTime ) { String sStartTime = null ; String sEndTime = null ; if ( ( startTime > Long . MIN_VALUE ) && ( startTime < Long . MAX_VALUE ) ) { sStartTime = CmsSearchUtil . getDateAsIso8601 ( new Date ( startTime ) ) ; } if ( ( endTime > Long . MIN_VALUE ) && ( endTime < Long . MAX_VALUE ) ) { sEndTime = CmsSearchUtil . getDateAsIso8601 ( new Date ( endTime ) ) ; } final String rangeString = CmsSearchUtil . getSolrRangeString ( sStartTime , sEndTime ) ; return String . format ( "%s:%s" , searchField , rangeString ) ; }
Returns a time interval as Solr compatible query string .
21,510
public static String getSolrRangeString ( String from , String to ) { if ( CmsStringUtil . isEmptyOrWhitespaceOnly ( from ) ) { from = "*" ; } if ( CmsStringUtil . isEmptyOrWhitespaceOnly ( to ) ) { to = "*" ; } return String . format ( "[%s TO %s]" , from , to ) ; }
Returns a string that represents a valid Solr query range .
21,511
public static Collection < ContentStream > toContentStreams ( final String str , final String contentType ) { if ( str == null ) { return null ; } ArrayList < ContentStream > streams = new ArrayList < > ( 1 ) ; ContentStreamBase ccc = new ContentStreamBase . StringStream ( str ) ; ccc . setContentType ( contentType ) ; streams . add ( ccc ) ; return streams ; }
Take a string and make it an iterable ContentStream
21,512
public static String paramMapToString ( final Map < String , String [ ] > parameters ) { final StringBuffer result = new StringBuffer ( ) ; for ( final String key : parameters . keySet ( ) ) { String [ ] values = parameters . get ( key ) ; if ( null == values ) { result . append ( key ) . append ( '&' ) ; } else { for ( final String value : parameters . get ( key ) ) { result . append ( key ) . append ( '=' ) . append ( CmsEncoder . encode ( value ) ) . append ( '&' ) ; } } } if ( result . length ( ) > 0 ) { result . setLength ( result . length ( ) - 1 ) ; } return result . toString ( ) ; }
Converts a parameter map to the parameter string .
21,513
String getFacetParamKey ( String facet ) { I_CmsSearchControllerFacetField fieldFacet = m_result . getController ( ) . getFieldFacets ( ) . getFieldFacetController ( ) . get ( facet ) ; if ( fieldFacet != null ) { return fieldFacet . getConfig ( ) . getParamKey ( ) ; } I_CmsSearchControllerFacetRange rangeFacet = m_result . getController ( ) . getRangeFacets ( ) . getRangeFacetController ( ) . get ( facet ) ; if ( rangeFacet != null ) { return rangeFacet . getConfig ( ) . getParamKey ( ) ; } I_CmsSearchControllerFacetQuery queryFacet = m_result . getController ( ) . getQueryFacet ( ) ; if ( ( queryFacet != null ) && queryFacet . getConfig ( ) . getName ( ) . equals ( facet ) ) { return queryFacet . getConfig ( ) . getParamKey ( ) ; } LOG . warn ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_FACET_NOT_CONFIGURED_1 , facet ) , new Throwable ( ) ) ; return null ; }
Returns the parameter key of the facet with the given name .
21,514
public static void closeWindow ( Component component ) { Window window = getWindow ( component ) ; if ( window != null ) { window . close ( ) ; } }
Closes the window containing the given component .
21,515
@ SuppressWarnings ( "unchecked" ) public static < T > void defaultHandleContextMenuForMultiselect ( Table table , CmsContextMenu menu , ItemClickEvent event , List < I_CmsSimpleContextMenuEntry < Collection < T > > > entries ) { if ( ! event . isCtrlKey ( ) && ! event . isShiftKey ( ) ) { if ( event . getButton ( ) . equals ( MouseButton . RIGHT ) ) { Collection < T > oldValue = ( ( Collection < T > ) table . getValue ( ) ) ; if ( oldValue . isEmpty ( ) || ! oldValue . contains ( event . getItemId ( ) ) ) { table . setValue ( new HashSet < Object > ( Arrays . asList ( event . getItemId ( ) ) ) ) ; } Collection < T > selection = ( Collection < T > ) table . getValue ( ) ; menu . setEntries ( entries , selection ) ; menu . openForTable ( event , table ) ; } } }
Simple context menu handler for multi - select tables .
21,516
public static IndexedContainer getGroupsOfUser ( CmsObject cms , CmsUser user , String caption , String iconProp , String ou , String propStatus , Function < CmsGroup , CmsCssIcon > iconProvider ) { IndexedContainer container = new IndexedContainer ( ) ; container . addContainerProperty ( caption , String . class , "" ) ; container . addContainerProperty ( ou , String . class , "" ) ; container . addContainerProperty ( propStatus , Boolean . class , new Boolean ( true ) ) ; if ( iconProvider != null ) { container . addContainerProperty ( iconProp , CmsCssIcon . class , null ) ; } try { for ( CmsGroup group : cms . getGroupsOfUser ( user . getName ( ) , true ) ) { Item item = container . addItem ( group ) ; item . getItemProperty ( caption ) . setValue ( group . getSimpleName ( ) ) ; item . getItemProperty ( ou ) . setValue ( group . getOuFqn ( ) ) ; if ( iconProvider != null ) { item . getItemProperty ( iconProp ) . setValue ( iconProvider . apply ( group ) ) ; } } } catch ( CmsException e ) { LOG . error ( "Unable to read groups from user" , e ) ; } return container ; }
Gets container with alls groups of a certain user .
21,517
public static IndexedContainer getPrincipalContainer ( CmsObject cms , List < ? extends I_CmsPrincipal > list , String captionID , String descID , String iconID , String ouID , String icon , List < FontIcon > iconList ) { IndexedContainer res = new IndexedContainer ( ) ; res . addContainerProperty ( captionID , String . class , "" ) ; res . addContainerProperty ( ouID , String . class , "" ) ; res . addContainerProperty ( iconID , FontIcon . class , new CmsCssIcon ( icon ) ) ; if ( descID != null ) { res . addContainerProperty ( descID , String . class , "" ) ; } for ( I_CmsPrincipal group : list ) { Item item = res . addItem ( group ) ; item . getItemProperty ( captionID ) . setValue ( group . getSimpleName ( ) ) ; item . getItemProperty ( ouID ) . setValue ( group . getOuFqn ( ) ) ; if ( descID != null ) { item . getItemProperty ( descID ) . setValue ( group . getDescription ( A_CmsUI . get ( ) . getLocale ( ) ) ) ; } } for ( int i = 0 ; i < iconList . size ( ) ; i ++ ) { res . getItem ( res . getIdByIndex ( i ) ) . getItemProperty ( iconID ) . setValue ( iconList . get ( i ) ) ; } return res ; }
Get container for principal .
21,518
public static void setFilterBoxStyle ( TextField searchBox ) { searchBox . setIcon ( FontOpenCms . FILTER ) ; searchBox . setPlaceholder ( org . opencms . ui . apps . Messages . get ( ) . getBundle ( UI . getCurrent ( ) . getLocale ( ) ) . key ( org . opencms . ui . apps . Messages . GUI_EXPLORER_FILTER_0 ) ) ; searchBox . addStyleName ( ValoTheme . TEXTFIELD_INLINE_ICON ) ; }
Configures a text field to look like a filter box for a table .
21,519
protected ZipEntry getZipEntry ( String filename ) throws ZipException { ZipEntry entry = getZipFile ( ) . getEntry ( filename ) ; if ( ( entry == null ) && filename . startsWith ( "/" ) ) { entry = m_zipFile . getEntry ( filename . substring ( 1 ) ) ; } if ( entry == null ) { throw new ZipException ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_IMPORTEXPORT_FILE_NOT_FOUND_IN_ZIP_1 , filename ) ) ; } return entry ; }
Returns the zip entry for a file in the archive .
21,520
protected void appenHtmlFooter ( StringBuffer buffer ) { if ( m_configuredFooter != null ) { buffer . append ( m_configuredFooter ) ; } else { buffer . append ( " </body>\r\n" + "</html>" ) ; } }
Append the html - code to finish a html mail message to the given buffer .
21,521
public void openReport ( String newState , A_CmsReportThread thread , String label ) { setReport ( newState , thread ) ; m_labels . put ( thread , label ) ; openSubView ( newState , true ) ; }
Changes to a new sub - view and stores a report to be displayed by that subview . <p<
21,522
public static CmsUUID readId ( JSONObject obj , String key ) { String strValue = obj . optString ( key ) ; if ( ! CmsUUID . isValidUUID ( strValue ) ) { return null ; } return new CmsUUID ( strValue ) ; }
Reads a UUID from a JSON object .
21,523
public void setSiteRoot ( String siteRoot ) { if ( siteRoot != null ) { siteRoot = siteRoot . replaceFirst ( "/$" , "" ) ; } m_siteRoot = siteRoot ; }
Sets the site root .
21,524
public JSONObject toJson ( ) throws JSONException { JSONObject result = new JSONObject ( ) ; if ( m_detailId != null ) { result . put ( JSON_DETAIL , "" + m_detailId ) ; } if ( m_siteRoot != null ) { result . put ( JSON_SITEROOT , m_siteRoot ) ; } if ( m_structureId != null ) { result . put ( JSON_STRUCTUREID , "" + m_structureId ) ; } if ( m_projectId != null ) { result . put ( JSON_PROJECT , "" + m_projectId ) ; } if ( m_type != null ) { result . put ( JSON_TYPE , "" + m_type . getJsonId ( ) ) ; } return result ; }
Converts this object to JSON .
21,525
public String updateContextAndGetFavoriteUrl ( CmsObject cms ) throws CmsException { CmsResourceFilter filter = CmsResourceFilter . IGNORE_EXPIRATION ; CmsProject project = null ; switch ( getType ( ) ) { case explorerFolder : CmsResource folder = cms . readResource ( getStructureId ( ) , filter ) ; project = cms . readProject ( getProjectId ( ) ) ; cms . getRequestContext ( ) . setSiteRoot ( getSiteRoot ( ) ) ; cms . getRequestContext ( ) . setCurrentProject ( project ) ; String explorerLink = CmsVaadinUtils . getWorkplaceLink ( ) + "#!" + CmsFileExplorerConfiguration . APP_ID + "/" + getProjectId ( ) + "!!" + getSiteRoot ( ) + "!!" + cms . getSitePath ( folder ) ; return explorerLink ; case page : project = cms . readProject ( getProjectId ( ) ) ; CmsResource target = cms . readResource ( getStructureId ( ) , filter ) ; CmsResource detailContent = null ; String link = null ; cms . getRequestContext ( ) . setCurrentProject ( project ) ; cms . getRequestContext ( ) . setSiteRoot ( getSiteRoot ( ) ) ; if ( getDetailId ( ) != null ) { detailContent = cms . readResource ( getDetailId ( ) ) ; link = OpenCms . getLinkManager ( ) . substituteLinkForUnknownTarget ( cms , cms . getSitePath ( detailContent ) , cms . getSitePath ( target ) , false ) ; } else { link = OpenCms . getLinkManager ( ) . substituteLink ( cms , target ) ; } return link ; default : return null ; } }
Prepares the CmsObject for jumping to this favorite location and returns the appropriate URL .
21,526
public static void openFavoriteDialog ( CmsFileExplorer explorer ) { try { CmsExplorerFavoriteContext context = new CmsExplorerFavoriteContext ( A_CmsUI . getCmsObject ( ) , explorer ) ; CmsFavoriteDialog dialog = new CmsFavoriteDialog ( context , new CmsFavoriteDAO ( A_CmsUI . getCmsObject ( ) ) ) ; Window window = CmsBasicDialog . prepareWindow ( DialogWidth . max ) ; window . setContent ( dialog ) ; window . setCaption ( CmsVaadinUtils . getMessageText ( org . opencms . ui . Messages . GUI_FAVORITES_DIALOG_TITLE_0 ) ) ; A_CmsUI . get ( ) . addWindow ( window ) ; window . center ( ) ; } catch ( CmsException e ) { CmsErrorDialog . showErrorDialog ( e ) ; } }
Opens the favorite dialog .
21,527
public static CmsResource getDescriptor ( CmsObject cms , String basename ) { CmsSolrQuery query = new CmsSolrQuery ( ) ; query . setResourceTypes ( CmsMessageBundleEditorTypes . BundleType . DESCRIPTOR . toString ( ) ) ; query . setFilterQueries ( "filename:\"" + basename + CmsMessageBundleEditorTypes . Descriptor . POSTFIX + "\"" ) ; query . add ( "fl" , "path" ) ; CmsSolrResultList results ; try { boolean isOnlineProject = cms . getRequestContext ( ) . getCurrentProject ( ) . isOnlineProject ( ) ; String indexName = isOnlineProject ? CmsSolrIndex . DEFAULT_INDEX_NAME_ONLINE : CmsSolrIndex . DEFAULT_INDEX_NAME_OFFLINE ; results = OpenCms . getSearchManager ( ) . getIndexSolr ( indexName ) . search ( cms , query , true , null , true , null ) ; } catch ( CmsSearchException e ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERR_BUNDLE_DESCRIPTOR_SEARCH_ERROR_0 ) , e ) ; return null ; } switch ( results . size ( ) ) { case 0 : return null ; case 1 : return results . get ( 0 ) ; default : String files = "" ; for ( CmsResource res : results ) { files += " " + res . getRootPath ( ) ; } LOG . warn ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERR_BUNDLE_DESCRIPTOR_NOT_UNIQUE_1 , files ) ) ; return results . get ( 0 ) ; } }
Returns the bundle descriptor for the bundle with the provided base name .
21,528
static void showWarning ( final String caption , final String description ) { Notification warning = new Notification ( caption , description , Type . WARNING_MESSAGE , true ) ; warning . setDelayMsec ( - 1 ) ; warning . show ( UI . getCurrent ( ) . getPage ( ) ) ; }
Displays a localized warning .
21,529
public void setDateOnly ( boolean dateOnly ) { if ( m_dateOnly != dateOnly ) { m_dateOnly = dateOnly ; if ( m_dateOnly ) { m_time . removeFromParent ( ) ; m_am . removeFromParent ( ) ; m_pm . removeFromParent ( ) ; } else { m_timeField . add ( m_time ) ; m_timeField . add ( m_am ) ; m_timeField . add ( m_pm ) ; } } }
Sets the value if the date only should be shown .
21,530
@ UiHandler ( "m_addButton" ) void addButtonClick ( ClickEvent e ) { if ( null != m_newDate . getValue ( ) ) { m_dateList . addDate ( m_newDate . getValue ( ) ) ; m_newDate . setValue ( null ) ; if ( handleChange ( ) ) { m_controller . setDates ( m_dateList . getDates ( ) ) ; } } }
Handle click on Add button .
21,531
@ UiHandler ( "m_dateList" ) void dateListValueChange ( ValueChangeEvent < SortedSet < Date > > event ) { if ( handleChange ( ) ) { m_controller . setDates ( event . getValue ( ) ) ; } }
Handle value change event on the individual dates list .
21,532
public String remove ( Object key ) { String result = m_configurationStrings . remove ( key ) ; m_configurationObjects . remove ( key ) ; return result ; }
Removes a parameter from this configuration .
21,533
private boolean loadCustomErrorPage ( CmsObject cms , HttpServletRequest req , HttpServletResponse res , String rootPath ) { try { CmsSite errorSite = OpenCms . getSiteManager ( ) . getSiteForRootPath ( rootPath ) ; cms . getRequestContext ( ) . setSiteRoot ( errorSite . getSiteRoot ( ) ) ; String relPath = cms . getRequestContext ( ) . removeSiteRoot ( rootPath ) ; if ( cms . existsResource ( relPath ) ) { cms . getRequestContext ( ) . setUri ( relPath ) ; OpenCms . getResourceManager ( ) . loadResource ( cms , cms . readResource ( relPath ) , req , res ) ; return true ; } else { return false ; } } catch ( Throwable e ) { LOG . error ( e . getMessage ( ) , e ) ; return false ; } }
Tries to load the custom error page at the given rootPath .
21,534
private boolean tryCustomErrorPage ( CmsObject cms , HttpServletRequest req , HttpServletResponse res , int errorCode ) { String siteRoot = OpenCms . getSiteManager ( ) . matchRequest ( req ) . getSiteRoot ( ) ; CmsSite site = OpenCms . getSiteManager ( ) . getSiteForSiteRoot ( siteRoot ) ; if ( site != null ) { String currentSiteRoot = cms . getRequestContext ( ) . getSiteRoot ( ) ; String currentUri = cms . getRequestContext ( ) . getUri ( ) ; try { if ( site . getErrorPage ( ) != null ) { String rootPath = site . getErrorPage ( ) ; if ( loadCustomErrorPage ( cms , req , res , rootPath ) ) { return true ; } } String rootPath = CmsStringUtil . joinPaths ( siteRoot , "/.errorpages/handle" + errorCode + ".html" ) ; if ( loadCustomErrorPage ( cms , req , res , rootPath ) ) { return true ; } } finally { cms . getRequestContext ( ) . setSiteRoot ( currentSiteRoot ) ; cms . getRequestContext ( ) . setUri ( currentUri ) ; } } return false ; }
Tries to load a site specific error page . If
21,535
private CmsVfsEntryBean buildVfsEntryBeanForQuickSearch ( CmsResource resource , Multimap < CmsResource , CmsResource > childMap , Set < CmsResource > filterMatches , Set < String > parentPaths , boolean isRoot ) throws CmsException { CmsObject cms = getCmsObject ( ) ; String title = cms . readPropertyObject ( resource , CmsPropertyDefinition . PROPERTY_TITLE , false ) . getValue ( ) ; boolean isMatch = filterMatches . contains ( resource ) ; List < CmsVfsEntryBean > childBeans = Lists . newArrayList ( ) ; Collection < CmsResource > children = childMap . get ( resource ) ; if ( ! children . isEmpty ( ) ) { for ( CmsResource child : children ) { CmsVfsEntryBean childBean = buildVfsEntryBeanForQuickSearch ( child , childMap , filterMatches , parentPaths , false ) ; childBeans . add ( childBean ) ; } } else if ( filterMatches . contains ( resource ) ) { if ( parentPaths . contains ( resource . getRootPath ( ) ) ) { childBeans = null ; } } String rootPath = resource . getRootPath ( ) ; CmsVfsEntryBean result = new CmsVfsEntryBean ( rootPath , resource . getStructureId ( ) , title , CmsIconUtil . getIconClasses ( CmsIconUtil . getDisplayType ( cms , resource ) , resource . getName ( ) , true ) , isRoot , isEditable ( cms , resource ) , childBeans , isMatch ) ; String siteRoot = null ; if ( OpenCms . getSiteManager ( ) . startsWithShared ( rootPath ) ) { siteRoot = OpenCms . getSiteManager ( ) . getSharedFolder ( ) ; } else { String tempSiteRoot = OpenCms . getSiteManager ( ) . getSiteRoot ( rootPath ) ; if ( tempSiteRoot != null ) { siteRoot = tempSiteRoot ; } else { siteRoot = "" ; } } result . setSiteRoot ( siteRoot ) ; return result ; }
Recursively builds the VFS entry bean for the quick filtering function in the folder tab . <p<
21,536
protected void doPurge ( Runnable afterPurgeAction ) { if ( LOG . isInfoEnabled ( ) ) { LOG . info ( org . opencms . flex . Messages . get ( ) . getBundle ( ) . key ( org . opencms . flex . Messages . LOG_FLEXCACHE_WILL_PURGE_JSP_REPOSITORY_0 ) ) ; } File d ; d = new File ( getJspRepository ( ) + CmsFlexCache . REPOSITORY_ONLINE + File . separator ) ; CmsFileUtil . purgeDirectory ( d ) ; d = new File ( getJspRepository ( ) + CmsFlexCache . REPOSITORY_OFFLINE + File . separator ) ; CmsFileUtil . purgeDirectory ( d ) ; if ( afterPurgeAction != null ) { afterPurgeAction . run ( ) ; } if ( LOG . isInfoEnabled ( ) ) { LOG . info ( org . opencms . flex . Messages . get ( ) . getBundle ( ) . key ( org . opencms . flex . Messages . LOG_FLEXCACHE_PURGED_JSP_REPOSITORY_0 ) ) ; } }
Purges the JSP repository . <p<
21,537
private void wrongUsage ( ) { String usage = "Usage: java -cp $PATH_TO_OPENCMS_JAR org.opencms.rmi.CmsRemoteShellClient\n" + " -script=[path to script] (optional) \n" + " -registryPort=[port of RMI registry] (optional, default is " + CmsRemoteShellConstants . DEFAULT_PORT + ")\n" + " -additional=[additional commands class name] (optional)" ; System . out . println ( usage ) ; System . exit ( 1 ) ; }
Displays text which shows the valid command line parameters and then exits .
21,538
public void setAddContentInfo ( final Boolean doAddInfo ) { if ( ( null != doAddInfo ) && doAddInfo . booleanValue ( ) && ( null != m_addContentInfoForEntries ) ) { m_addContentInfoForEntries = Integer . valueOf ( DEFAULT_CONTENTINFO_ROWS ) ; } }
Setter for addContentInfo indicating if content information should be added .
21,539
public void setFileFormat ( String fileFormat ) { if ( fileFormat . toUpperCase ( ) . equals ( FileFormat . JSON . toString ( ) ) ) { m_fileFormat = FileFormat . JSON ; } }
Setter for the file format .
21,540
private void addContentInfo ( ) { if ( ! m_cms . getRequestContext ( ) . getCurrentProject ( ) . isOnlineProject ( ) && ( null == m_searchController . getCommon ( ) . getConfig ( ) . getSolrIndex ( ) ) && ( null != m_addContentInfoForEntries ) ) { CmsSolrQuery query = new CmsSolrQuery ( ) ; m_searchController . addQueryParts ( query , m_cms ) ; query . setStart ( Integer . valueOf ( 0 ) ) ; query . setRows ( m_addContentInfoForEntries ) ; CmsContentLoadCollectorInfo info = new CmsContentLoadCollectorInfo ( ) ; info . setCollectorClass ( this . getClass ( ) . getName ( ) ) ; info . setCollectorParams ( query . getQuery ( ) ) ; info . setId ( ( new CmsUUID ( ) ) . getStringValue ( ) ) ; if ( CmsJspTagEditable . getDirectEditProvider ( pageContext ) != null ) { try { CmsJspTagEditable . getDirectEditProvider ( pageContext ) . insertDirectEditListMetadata ( pageContext , info ) ; } catch ( JspException e ) { LOG . error ( "Could not write content info." , e ) ; } } } }
Adds the content info for the collected resources used in the This page publish dialog .
21,541
private I_CmsSearchResultWrapper getSearchResults ( ) { m_searchController . updateFromRequestParameters ( pageContext . getRequest ( ) . getParameterMap ( ) , false ) ; I_CmsSearchControllerCommon common = m_searchController . getCommon ( ) ; if ( common . getState ( ) . getQuery ( ) . isEmpty ( ) && ( ! common . getConfig ( ) . getIgnoreQueryParam ( ) && ! common . getConfig ( ) . getSearchForEmptyQueryParam ( ) ) ) { return new CmsSearchResultWrapper ( m_searchController , null , null , m_cms , null ) ; } Map < String , String [ ] > queryParams = null ; boolean isEditMode = CmsJspTagEditable . isEditableRequest ( pageContext . getRequest ( ) ) ; if ( isEditMode ) { String params = "" ; if ( common . getConfig ( ) . getIgnoreReleaseDate ( ) ) { params += "&fq=released:[* TO *]" ; } if ( common . getConfig ( ) . getIgnoreExpirationDate ( ) ) { params += "&fq=expired:[* TO *]" ; } if ( ! params . isEmpty ( ) ) { queryParams = CmsRequestUtil . createParameterMap ( params . substring ( 1 ) ) ; } } CmsSolrQuery query = new CmsSolrQuery ( null , queryParams ) ; m_searchController . addQueryParts ( query , m_cms ) ; try { CmsSolrResultList solrResultList = m_index . search ( m_cms , query . clone ( ) , true , isEditMode ? CmsResourceFilter . IGNORE_EXPIRATION : null ) ; return new CmsSearchResultWrapper ( m_searchController , solrResultList , query , m_cms , null ) ; } catch ( CmsSearchException e ) { LOG . warn ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_TAG_SEARCH_SEARCH_FAILED_0 ) , e ) ; return new CmsSearchResultWrapper ( m_searchController , null , query , m_cms , e ) ; } }
Here the search query is composed and executed . The result is wrapped in an easily usable form . It is exposed to the JSP via the tag s var attribute .
21,542
public Date toDate ( Object date ) { Date d = null ; if ( null != date ) { if ( date instanceof Date ) { d = ( Date ) date ; } else if ( date instanceof Long ) { d = new Date ( ( ( Long ) date ) . longValue ( ) ) ; } else { try { long l = Long . parseLong ( date . toString ( ) ) ; d = new Date ( l ) ; } catch ( Exception e ) { } } } return d ; }
Converts the provided object to a date if possible .
21,543
public synchronized void stop ( ) { if ( m_thread != null ) { long timeBeforeShutdownWasCalled = System . currentTimeMillis ( ) ; JLANServer . shutdownServer ( new String [ ] { } ) ; while ( m_thread . isAlive ( ) && ( ( System . currentTimeMillis ( ) - timeBeforeShutdownWasCalled ) < MAX_SHUTDOWN_WAIT_MILLIS ) ) { try { Thread . sleep ( 500 ) ; } catch ( InterruptedException e ) { } } } }
Tries to stop the JLAN server and return after it is stopped but will also return if the thread hasn t stopped after MAX_SHUTDOWN_WAIT_MILLIS .
21,544
public boolean needToSetCategoryFolder ( ) { if ( m_adeModuleVersion == null ) { return true ; } CmsModuleVersion categoryFolderUpdateVersion = new CmsModuleVersion ( "9.0.0" ) ; return ( m_adeModuleVersion . compareTo ( categoryFolderUpdateVersion ) == - 1 ) ; }
Checks if the categoryfolder setting needs to be updated .
21,545
public void setWeekDays ( SortedSet < WeekDay > weekDays ) { final SortedSet < WeekDay > newWeekDays = null == weekDays ? new TreeSet < WeekDay > ( ) : weekDays ; SortedSet < WeekDay > currentWeekDays = m_model . getWeekDays ( ) ; if ( ! currentWeekDays . equals ( newWeekDays ) ) { conditionallyRemoveExceptionsOnChange ( new Command ( ) { public void execute ( ) { m_model . setWeekDays ( newWeekDays ) ; onValueChange ( ) ; } } , ! newWeekDays . containsAll ( m_model . getWeekDays ( ) ) ) ; } }
Set the weekdays at which the event should take place .
21,546
protected void switchTab ( ) { Component tab = m_tab . getSelectedTab ( ) ; int pos = m_tab . getTabPosition ( m_tab . getTab ( tab ) ) ; if ( m_isWebOU ) { if ( pos == 0 ) { pos = 1 ; } } m_tab . setSelectedTab ( pos + 1 ) ; }
Switches to the next tab .
21,547
protected void onEditTitleTextBox ( TextBox box ) { if ( m_titleEditHandler != null ) { m_titleEditHandler . handleEdit ( m_title , box ) ; return ; } String text = box . getText ( ) ; box . removeFromParent ( ) ; m_title . setText ( text ) ; m_title . setVisible ( true ) ; }
Internal method which is called when the user has finished editing the title .
21,548
public void setPatternScheme ( final boolean isByWeekDay , final boolean fireChange ) { if ( isByWeekDay ^ ( null != m_model . getWeekDay ( ) ) ) { removeExceptionsOnChange ( new Command ( ) { public void execute ( ) { if ( isByWeekDay ) { m_model . setWeekOfMonth ( getPatternDefaultValues ( ) . getWeekOfMonth ( ) ) ; m_model . setWeekDay ( getPatternDefaultValues ( ) . getWeekDay ( ) ) ; } else { m_model . clearWeekDays ( ) ; m_model . clearWeeksOfMonth ( ) ; m_model . setDayOfMonth ( getPatternDefaultValues ( ) . getDayOfMonth ( ) ) ; } m_model . setInterval ( getPatternDefaultValues ( ) . getInterval ( ) ) ; if ( fireChange ) { onValueChange ( ) ; } } } ) ; } }
Set the pattern scheme to either by weekday or by day of month .
21,549
public void setWeekDay ( String dayString ) { final WeekDay day = WeekDay . valueOf ( dayString ) ; if ( m_model . getWeekDay ( ) != day ) { removeExceptionsOnChange ( new Command ( ) { public void execute ( ) { m_model . setWeekDay ( day ) ; onValueChange ( ) ; } } ) ; } }
Set the week day the event should take place .
21,550
public void weeksChange ( String week , Boolean value ) { final WeekOfMonth changedWeek = WeekOfMonth . valueOf ( week ) ; boolean newValue = ( null != value ) && value . booleanValue ( ) ; boolean currentValue = m_model . getWeeksOfMonth ( ) . contains ( changedWeek ) ; if ( newValue != currentValue ) { if ( newValue ) { setPatternScheme ( true , false ) ; m_model . addWeekOfMonth ( changedWeek ) ; onValueChange ( ) ; } else { removeExceptionsOnChange ( new Command ( ) { public void execute ( ) { m_model . removeWeekOfMonth ( changedWeek ) ; onValueChange ( ) ; } } ) ; } } }
Handle a change in the weeks of month .
21,551
public void validateAliases ( final CmsUUID uuid , final Map < String , String > aliasPaths , final AsyncCallback < Map < String , String > > callback ) { CmsRpcAction < Map < String , String > > action = new CmsRpcAction < Map < String , String > > ( ) { public void execute ( ) { start ( 200 , true ) ; CmsCoreProvider . getVfsService ( ) . validateAliases ( uuid , aliasPaths , this ) ; } protected void onResponse ( Map < String , String > result ) { stop ( false ) ; callback . onSuccess ( result ) ; } } ; action . execute ( ) ; }
Validates aliases .
21,552
void setDayOfMonth ( String day ) { final int i = CmsSerialDateUtil . toIntWithDefault ( day , - 1 ) ; if ( m_model . getDayOfMonth ( ) != i ) { removeExceptionsOnChange ( new Command ( ) { public void execute ( ) { m_model . setDayOfMonth ( i ) ; onValueChange ( ) ; } } ) ; } }
Sets the day of the month .
21,553
private String convertOutputToHtml ( String content ) { if ( content . length ( ) == 0 ) { return "" ; } StringBuilder buffer = new StringBuilder ( ) ; for ( String line : content . split ( "\n" ) ) { buffer . append ( CmsEncoder . escapeXml ( line ) + "<br>" ) ; } return buffer . toString ( ) ; }
Converts the text stream data to HTML form .
21,554
private void writeToDelegate ( byte [ ] data ) { if ( m_delegateStream != null ) { try { m_delegateStream . write ( data ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } }
Writes data to delegate stream if it has been set .
21,555
public static String getStatusForItem ( Long lastActivity ) { if ( lastActivity . longValue ( ) < CmsSessionsTable . INACTIVE_LIMIT ) { return CmsVaadinUtils . getMessageText ( Messages . GUI_MESSAGES_BROADCAST_COLS_STATUS_ACTIVE_0 ) ; } return CmsVaadinUtils . getMessageText ( Messages . GUI_MESSAGES_BROADCAST_COLS_STATUS_INACTIVE_0 ) ; }
Gets the status text from given session .
21,556
public static void showUserInfo ( CmsSessionInfo session ) { final Window window = CmsBasicDialog . prepareWindow ( DialogWidth . wide ) ; CmsUserInfoDialog dialog = new CmsUserInfoDialog ( session , new Runnable ( ) { public void run ( ) { window . close ( ) ; } } ) ; window . setCaption ( CmsVaadinUtils . getMessageText ( Messages . GUI_MESSAGES_SHOW_USER_0 ) ) ; window . setContent ( dialog ) ; A_CmsUI . get ( ) . addWindow ( window ) ; }
Shows a dialog with user information for given session .
21,557
public void onBrowserEvent ( Event event ) { super . onBrowserEvent ( event ) ; switch ( DOM . eventGetType ( event ) ) { case Event . ONMOUSEUP : Event . releaseCapture ( m_slider . getElement ( ) ) ; m_capturedMouse = false ; break ; case Event . ONMOUSEDOWN : Event . setCapture ( m_slider . getElement ( ) ) ; m_capturedMouse = true ; case Event . ONMOUSEMOVE : if ( m_capturedMouse ) { event . preventDefault ( ) ; float x = ( ( event . getClientX ( ) - ( m_colorUnderlay . getAbsoluteLeft ( ) ) ) + Window . getScrollLeft ( ) ) ; float y = ( ( event . getClientY ( ) - ( m_colorUnderlay . getAbsoluteTop ( ) ) ) + Window . getScrollTop ( ) ) ; if ( m_parent != null ) { m_parent . onMapSelected ( x , y ) ; } setSliderPosition ( x , y ) ; } default : } }
Fired whenever a browser event is received .
21,558
private void addChildrenForGroupsNode ( I_CmsOuTreeType type , String ouItem ) { try { List < CmsGroup > groups = m_app . readGroupsForOu ( m_cms , ouItem . substring ( 1 ) , type , false ) ; for ( CmsGroup group : groups ) { Pair < String , CmsUUID > key = Pair . of ( type . getId ( ) , group . getId ( ) ) ; Item groupItem = m_treeContainer . addItem ( key ) ; if ( groupItem == null ) { groupItem = getItem ( key ) ; } groupItem . getItemProperty ( PROP_SID ) . setValue ( group . getId ( ) ) ; groupItem . getItemProperty ( PROP_NAME ) . setValue ( getIconCaptionHTML ( group , CmsOuTreeType . GROUP ) ) ; groupItem . getItemProperty ( PROP_TYPE ) . setValue ( type ) ; setChildrenAllowed ( key , false ) ; m_treeContainer . setParent ( key , ouItem ) ; } } catch ( CmsException e ) { LOG . error ( "Can not read group" , e ) ; } }
Add groups for given group parent item .
21,559
private void addChildrenForRolesNode ( String ouItem ) { try { List < CmsRole > roles = OpenCms . getRoleManager ( ) . getRoles ( m_cms , ouItem . substring ( 1 ) , false ) ; CmsRole . applySystemRoleOrder ( roles ) ; for ( CmsRole role : roles ) { String roleId = ouItem + "/" + role . getId ( ) ; Item roleItem = m_treeContainer . addItem ( roleId ) ; if ( roleItem == null ) { roleItem = getItem ( roleId ) ; } roleItem . getItemProperty ( PROP_NAME ) . setValue ( getIconCaptionHTML ( role , CmsOuTreeType . ROLE ) ) ; roleItem . getItemProperty ( PROP_TYPE ) . setValue ( CmsOuTreeType . ROLE ) ; setChildrenAllowed ( roleId , false ) ; m_treeContainer . setParent ( roleId , ouItem ) ; } } catch ( CmsException e ) { LOG . error ( "Can not read group" , e ) ; } }
Add roles for given role parent item .
21,560
public static boolean checkConfiguredInModules ( ) { Boolean result = m_moduleCheckCache . get ( ) ; if ( result == null ) { result = Boolean . valueOf ( getConfiguredTemplateMapping ( ) != null ) ; m_moduleCheckCache . set ( result ) ; } return result . booleanValue ( ) ; }
Checks if template mapper is configured in modules .
21,561
@ SuppressWarnings ( "unused" ) public static void addTo ( AbstractSingleComponentContainer componentContainer , int scrollBarrier , int barrierMargin , String styleName ) { new CmsScrollPositionCss ( componentContainer , scrollBarrier , barrierMargin , styleName ) ; }
Adds the scroll position CSS extension to the given component
21,562
protected boolean checkvalue ( String colorvalue ) { boolean valid = validateColorValue ( colorvalue ) ; if ( valid ) { if ( colorvalue . length ( ) == 4 ) { char [ ] chr = colorvalue . toCharArray ( ) ; for ( int i = 1 ; i < 4 ; i ++ ) { String foo = String . valueOf ( chr [ i ] ) ; colorvalue = colorvalue . replaceFirst ( foo , foo + foo ) ; } } m_textboxColorValue . setValue ( colorvalue , true ) ; m_colorField . getElement ( ) . getStyle ( ) . setBackgroundColor ( colorvalue ) ; m_colorValue = colorvalue ; } return valid ; }
Validates the inputed color value .
21,563
protected AllowableActions collectAllowableActions ( CmsObject cms , CmsResource file ) { try { if ( file == null ) { throw new IllegalArgumentException ( "File must not be null!" ) ; } CmsLock lock = cms . getLock ( file ) ; CmsUser user = cms . getRequestContext ( ) . getCurrentUser ( ) ; boolean canWrite = ! cms . getRequestContext ( ) . getCurrentProject ( ) . isOnlineProject ( ) && ( lock . isOwnedBy ( user ) || lock . isLockableBy ( user ) ) && cms . hasPermissions ( file , CmsPermissionSet . ACCESS_WRITE , false , CmsResourceFilter . DEFAULT ) ; boolean isReadOnly = ! canWrite ; boolean isFolder = file . isFolder ( ) ; boolean isRoot = file . getRootPath ( ) . length ( ) <= 1 ; Set < Action > aas = new LinkedHashSet < Action > ( ) ; addAction ( aas , Action . CAN_GET_OBJECT_PARENTS , ! isRoot ) ; addAction ( aas , Action . CAN_GET_PROPERTIES , true ) ; addAction ( aas , Action . CAN_UPDATE_PROPERTIES , ! isReadOnly ) ; addAction ( aas , Action . CAN_MOVE_OBJECT , ! isReadOnly && ! isRoot ) ; addAction ( aas , Action . CAN_DELETE_OBJECT , ! isReadOnly && ! isRoot ) ; if ( isFolder ) { addAction ( aas , Action . CAN_GET_DESCENDANTS , true ) ; addAction ( aas , Action . CAN_GET_CHILDREN , true ) ; addAction ( aas , Action . CAN_GET_FOLDER_PARENT , ! isRoot ) ; addAction ( aas , Action . CAN_GET_FOLDER_TREE , true ) ; addAction ( aas , Action . CAN_CREATE_DOCUMENT , ! isReadOnly ) ; addAction ( aas , Action . CAN_CREATE_FOLDER , ! isReadOnly ) ; addAction ( aas , Action . CAN_DELETE_TREE , ! isReadOnly ) ; } else { addAction ( aas , Action . CAN_GET_CONTENT_STREAM , true ) ; addAction ( aas , Action . CAN_SET_CONTENT_STREAM , ! isReadOnly ) ; addAction ( aas , Action . CAN_GET_ALL_VERSIONS , true ) ; } AllowableActionsImpl result = new AllowableActionsImpl ( ) ; result . setAllowableActions ( aas ) ; return result ; } catch ( CmsException e ) { handleCmsException ( e ) ; return null ; } }
Compiles the allowable actions for a file or folder .
21,564
public static String getStatusText ( int nHttpStatusCode ) { Integer intKey = new Integer ( nHttpStatusCode ) ; if ( ! mapStatusCodes . containsKey ( intKey ) ) { return "" ; } else { return mapStatusCodes . get ( intKey ) ; } }
Returns the HTTP status text for the HTTP or WebDav status code specified by looking it up in the static mapping . This is a static function .
21,565
private boolean addType ( TypeDefinition type ) { if ( type == null ) { return false ; } if ( type . getBaseTypeId ( ) == null ) { return false ; } TypeDefinition baseType = null ; if ( type . getBaseTypeId ( ) == BaseTypeId . CMIS_DOCUMENT ) { baseType = copyTypeDefintion ( m_types . get ( DOCUMENT_TYPE_ID ) . getTypeDefinition ( ) ) ; } else if ( type . getBaseTypeId ( ) == BaseTypeId . CMIS_FOLDER ) { baseType = copyTypeDefintion ( m_types . get ( FOLDER_TYPE_ID ) . getTypeDefinition ( ) ) ; } else if ( type . getBaseTypeId ( ) == BaseTypeId . CMIS_RELATIONSHIP ) { baseType = copyTypeDefintion ( m_types . get ( RELATIONSHIP_TYPE_ID ) . getTypeDefinition ( ) ) ; } else if ( type . getBaseTypeId ( ) == BaseTypeId . CMIS_POLICY ) { baseType = copyTypeDefintion ( m_types . get ( POLICY_TYPE_ID ) . getTypeDefinition ( ) ) ; } else { return false ; } AbstractTypeDefinition newType = ( AbstractTypeDefinition ) copyTypeDefintion ( type ) ; for ( PropertyDefinition < ? > propDef : baseType . getPropertyDefinitions ( ) . values ( ) ) { ( ( AbstractPropertyDefinition < ? > ) propDef ) . setIsInherited ( Boolean . TRUE ) ; newType . addPropertyDefinition ( propDef ) ; } addTypeInternal ( newType ) ; return true ; }
Adds a type to collection with inheriting base type properties .
21,566
public String buildRadio ( String propName ) throws CmsException { String propVal = readProperty ( propName ) ; StringBuffer result = new StringBuffer ( "<table border=\"0\"><tr>" ) ; result . append ( "<td><input type=\"radio\" value=\"true\" onClick=\"checkNoIntern()\" name=\"" ) . append ( propName ) . append ( "\" " ) . append ( Boolean . valueOf ( propVal ) . booleanValue ( ) ? "checked=\"checked\"" : "" ) . append ( "/></td><td id=\"tablelabel\">" ) . append ( key ( Messages . GUI_LABEL_TRUE_0 ) ) . append ( "</td>" ) ; result . append ( "<td><input type=\"radio\" value=\"false\" onClick=\"checkNoIntern()\" name=\"" ) . append ( propName ) . append ( "\" " ) . append ( Boolean . valueOf ( propVal ) . booleanValue ( ) ? "" : "checked=\"checked\"" ) . append ( "/></td><td id=\"tablelabel\">" ) . append ( key ( Messages . GUI_LABEL_FALSE_0 ) ) . append ( "</td>" ) ; result . append ( "<td><input type=\"radio\" value=\"\" onClick=\"checkNoIntern()\" name=\"" ) . append ( propName ) . append ( "\" " ) . append ( CmsStringUtil . isEmpty ( propVal ) ? "checked=\"checked\"" : "" ) . append ( "/></td><td id=\"tablelabel\">" ) . append ( getPropertyInheritanceInfo ( propName ) ) . append ( "</td></tr></table>" ) ; return result . toString ( ) ; }
Builds the radio input to set the export and secure property .
21,567
public void setCategoryDisplayOptions ( String displayCategoriesByRepository , String displayCategorySelectionCollapsed ) { m_displayCategoriesByRepository = Boolean . parseBoolean ( displayCategoriesByRepository ) ; m_displayCategorySelectionCollapsed = Boolean . parseBoolean ( displayCategorySelectionCollapsed ) ; }
Sets the category display options that affect how the category selection dialog is shown .
21,568
protected boolean showMoreEntries ( Calendar nextDate , int previousOccurrences ) { switch ( getSerialEndType ( ) ) { case DATE : boolean moreByDate = nextDate . getTimeInMillis ( ) < m_endMillis ; boolean moreByOccurrences = previousOccurrences < CmsSerialDateUtil . getMaxEvents ( ) ; if ( moreByDate && ! moreByOccurrences ) { m_hasTooManyOccurrences = Boolean . TRUE ; } return moreByDate && moreByOccurrences ; case TIMES : case SINGLE : return previousOccurrences < getOccurrences ( ) ; default : throw new IllegalArgumentException ( ) ; } }
Check if the provided date or any date after it are part of the series .
21,569
private SortedSet < Date > calculateDates ( ) { if ( null == m_allDates ) { SortedSet < Date > result = new TreeSet < > ( ) ; if ( isAnyDatePossible ( ) ) { Calendar date = getFirstDate ( ) ; int previousOccurrences = 0 ; while ( showMoreEntries ( date , previousOccurrences ) ) { result . add ( date . getTime ( ) ) ; toNextDate ( date ) ; previousOccurrences ++ ; } } m_allDates = result ; } return m_allDates ; }
Calculates all dates of the series .
21,570
private SortedSet < Date > filterExceptions ( SortedSet < Date > dates ) { SortedSet < Date > result = new TreeSet < Date > ( ) ; for ( Date d : dates ) { if ( ! m_exceptions . contains ( d ) ) { result . add ( d ) ; } } return result ; }
Filters all exceptions from the provided dates .
21,571
private void setHeaderList ( Map < String , List < String > > headers , String name , String value ) { List < String > values = new ArrayList < String > ( ) ; values . add ( SET_HEADER + value ) ; headers . put ( name , values ) ; }
Helper method to set a value in the internal header list .
21,572
public static String changeFileNameSuffixTo ( String filename , String suffix ) { int dotPos = filename . lastIndexOf ( '.' ) ; if ( dotPos != - 1 ) { return filename . substring ( 0 , dotPos + 1 ) + suffix ; } else { return filename ; } }
Changes the given filenames suffix from the current suffix to the provided suffix .
21,573
public static final long parseDuration ( String durationStr , long defaultValue ) { durationStr = durationStr . toLowerCase ( ) . trim ( ) ; Matcher matcher = DURATION_NUMBER_AND_UNIT_PATTERN . matcher ( durationStr ) ; long millis = 0 ; boolean matched = false ; while ( matcher . find ( ) ) { long number = Long . valueOf ( matcher . group ( 1 ) ) . longValue ( ) ; String unit = matcher . group ( 2 ) ; long multiplier = 0 ; for ( int j = 0 ; j < DURATION_UNTIS . length ; j ++ ) { if ( unit . equals ( DURATION_UNTIS [ j ] ) ) { multiplier = DURATION_MULTIPLIERS [ j ] ; break ; } } if ( multiplier == 0 ) { LOG . warn ( "parseDuration: Unknown unit " + unit ) ; } else { matched = true ; } millis += number * multiplier ; } if ( ! matched ) { millis = defaultValue ; } return millis ; }
Parses a duration and returns the corresponding number of milliseconds .
21,574
public static StringTemplateGroup readStringTemplateGroup ( InputStream stream ) { try { return new StringTemplateGroup ( new InputStreamReader ( stream , "UTF-8" ) , DefaultTemplateLexer . class , new StringTemplateErrorListener ( ) { @ SuppressWarnings ( "synthetic-access" ) public void error ( String arg0 , Throwable arg1 ) { LOG . error ( arg0 + ": " + arg1 . getMessage ( ) , arg1 ) ; } @ SuppressWarnings ( "synthetic-access" ) public void warning ( String arg0 ) { LOG . warn ( arg0 ) ; } } ) ; } catch ( Exception e ) { LOG . error ( e . getLocalizedMessage ( ) , e ) ; return new StringTemplateGroup ( "dummy" ) ; } }
Reads a stringtemplate group from a stream .
21,575
public static void fire ( I_CmsHasDateBoxEventHandlers source , Date date , boolean isTyping ) { if ( TYPE != null ) { CmsDateBoxEvent event = new CmsDateBoxEvent ( date , isTyping ) ; source . fireEvent ( event ) ; } }
Fires the event .
21,576
protected CmsProject createAndSetModuleImportProject ( CmsObject cms , CmsModule module ) throws CmsException { CmsProject importProject = cms . createProject ( org . opencms . module . Messages . get ( ) . getBundle ( cms . getRequestContext ( ) . getLocale ( ) ) . key ( org . opencms . module . Messages . GUI_IMPORT_MODULE_PROJECT_NAME_1 , new Object [ ] { module . getName ( ) } ) , org . opencms . module . Messages . get ( ) . getBundle ( cms . getRequestContext ( ) . getLocale ( ) ) . key ( org . opencms . module . Messages . GUI_IMPORT_MODULE_PROJECT_DESC_1 , new Object [ ] { module . getName ( ) } ) , OpenCms . getDefaultUsers ( ) . getGroupAdministrators ( ) , OpenCms . getDefaultUsers ( ) . getGroupAdministrators ( ) , CmsProject . PROJECT_TYPE_TEMPORARY ) ; cms . getRequestContext ( ) . setCurrentProject ( importProject ) ; cms . copyResourceToProject ( "/" ) ; return importProject ; }
Creates the project used to import module resources and sets it on the CmsObject .
21,577
protected void deleteConflictingResources ( CmsObject cms , CmsModule module , Map < CmsUUID , CmsUUID > conflictingIds ) throws CmsException , Exception { CmsProject conflictProject = cms . createProject ( "Deletion of conflicting resources for " + module . getName ( ) , "Deletion of conflicting resources for " + module . getName ( ) , OpenCms . getDefaultUsers ( ) . getGroupAdministrators ( ) , OpenCms . getDefaultUsers ( ) . getGroupAdministrators ( ) , CmsProject . PROJECT_TYPE_TEMPORARY ) ; CmsObject deleteCms = OpenCms . initCmsObject ( cms ) ; deleteCms . getRequestContext ( ) . setCurrentProject ( conflictProject ) ; for ( CmsUUID vfsId : conflictingIds . values ( ) ) { CmsResource toDelete = deleteCms . readResource ( vfsId , CmsResourceFilter . ALL ) ; lock ( deleteCms , toDelete ) ; deleteCms . deleteResource ( toDelete , CmsResource . DELETE_PRESERVE_SIBLINGS ) ; } OpenCms . getPublishManager ( ) . publishProject ( deleteCms ) ; OpenCms . getPublishManager ( ) . waitWhileRunning ( ) ; }
Deletes and publishes resources with ID conflicts .
21,578
protected void parseLinks ( CmsObject cms ) throws CmsException { List < CmsResource > linkParseables = new ArrayList < > ( ) ; for ( CmsResourceImportData resData : m_moduleData . getResourceData ( ) ) { CmsResource importRes = resData . getImportResource ( ) ; if ( ( importRes != null ) && m_importIds . contains ( importRes . getStructureId ( ) ) && isLinkParsable ( importRes ) ) { linkParseables . add ( importRes ) ; } } m_report . println ( Messages . get ( ) . container ( Messages . RPT_START_PARSE_LINKS_0 ) , I_CmsReport . FORMAT_HEADLINE ) ; CmsImportVersion10 . parseLinks ( cms , linkParseables , m_report ) ; m_report . println ( Messages . get ( ) . container ( Messages . RPT_END_PARSE_LINKS_0 ) , I_CmsReport . FORMAT_HEADLINE ) ; }
Parses links for XMLContents etc .
21,579
protected void processDeletions ( CmsObject cms , List < CmsResource > toDelete ) throws CmsException { Collections . sort ( toDelete , ( a , b ) -> b . getRootPath ( ) . compareTo ( a . getRootPath ( ) ) ) ; for ( CmsResource deleteRes : toDelete ) { m_report . print ( org . opencms . importexport . Messages . get ( ) . container ( org . opencms . importexport . Messages . RPT_DELFOLDER_0 ) , I_CmsReport . FORMAT_NOTE ) ; m_report . print ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_ARGUMENT_1 , deleteRes . getRootPath ( ) ) ) ; CmsLock lock = cms . getLock ( deleteRes ) ; if ( lock . isUnlocked ( ) ) { lock ( cms , deleteRes ) ; } cms . deleteResource ( deleteRes , CmsResource . DELETE_PRESERVE_SIBLINGS ) ; m_report . println ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_OK_0 ) , I_CmsReport . FORMAT_OK ) ; } }
Handles the file deletions .
21,580
protected void runImportScript ( CmsObject cms , CmsModule module ) { LOG . info ( "Executing import script for module " + module . getName ( ) ) ; m_report . println ( org . opencms . module . Messages . get ( ) . container ( org . opencms . module . Messages . RPT_IMPORT_SCRIPT_HEADER_0 ) , I_CmsReport . FORMAT_HEADLINE ) ; String importScript = "echo on\n" + module . getImportScript ( ) ; ByteArrayOutputStream buffer = new ByteArrayOutputStream ( ) ; PrintStream out = new PrintStream ( buffer ) ; CmsShell shell = new CmsShell ( cms , "${user}@${project}:${siteroot}|${uri}>" , null , out , out ) ; shell . execute ( importScript ) ; String outputString = buffer . toString ( ) ; LOG . info ( "Shell output for import script was: \n" + outputString ) ; m_report . println ( org . opencms . module . Messages . get ( ) . container ( org . opencms . module . Messages . RPT_IMPORT_SCRIPT_OUTPUT_1 , outputString ) ) ; }
Runs the module import script .
21,581
public Map < String , List < Locale > > getAvailableLocales ( ) { if ( m_availableLocales == null ) { m_availableLocales = CmsCollectionsGenericWrapper . createLazyMap ( new CmsAvailableLocaleLoaderTransformer ( ) ) ; } return m_availableLocales ; }
Returns a lazily generated map from site paths of resources to the available locales for the resource .
21,582
private static CmsObject adjustSiteRootIfNecessary ( final CmsObject cms , final CmsModule module ) throws CmsException { CmsObject cmsClone ; if ( ( null == module . getSite ( ) ) || cms . getRequestContext ( ) . getSiteRoot ( ) . equals ( module . getSite ( ) ) ) { cmsClone = cms ; } else { cmsClone = OpenCms . initCmsObject ( cms ) ; cmsClone . getRequestContext ( ) . setSiteRoot ( module . getSite ( ) ) ; } return cmsClone ; }
Adjusts the site root and returns a cloned CmsObject iff the module has set an import site that differs from the site root of the CmsObject provided as argument . Otherwise returns the provided CmsObject unchanged .
21,583
public boolean shouldIncrementVersionBasedOnResources ( CmsObject cms ) throws CmsException { if ( m_checkpointTime == 0 ) { return true ; } CmsObject cmsClone = adjustSiteRootIfNecessary ( cms , this ) ; List < CmsResource > moduleResources = calculateModuleResources ( cmsClone , this ) ; for ( CmsResource resource : moduleResources ) { try { List < CmsResource > resourcesToCheck = Lists . newArrayList ( ) ; resourcesToCheck . add ( resource ) ; if ( resource . isFolder ( ) ) { resourcesToCheck . addAll ( cms . readResources ( resource , CmsResourceFilter . IGNORE_EXPIRATION , true ) ) ; } for ( CmsResource resourceToCheck : resourcesToCheck ) { if ( resourceToCheck . getDateLastModified ( ) > m_checkpointTime ) { return true ; } } } catch ( CmsException e ) { LOG . warn ( e . getLocalizedMessage ( ) , e ) ; continue ; } } return false ; }
Determines if the version should be incremented based on the module resources modification dates .
21,584
public Class < ? > getColumnType ( int c ) { for ( int r = 0 ; r < m_data . size ( ) ; r ++ ) { Object val = m_data . get ( r ) . get ( c ) ; if ( val != null ) { return val . getClass ( ) ; } } return Object . class ; }
Gets the type to use for the Vaadin table column corresponding to the c - th column in this result .
21,585
public String getCsv ( ) { StringWriter writer = new StringWriter ( ) ; try ( CSVWriter csv = new CSVWriter ( writer ) ) { List < String > headers = new ArrayList < > ( ) ; for ( String col : m_columns ) { headers . add ( col ) ; } csv . writeNext ( headers . toArray ( new String [ ] { } ) ) ; for ( List < Object > row : m_data ) { List < String > colCsv = new ArrayList < > ( ) ; for ( Object col : row ) { colCsv . add ( String . valueOf ( col ) ) ; } csv . writeNext ( colCsv . toArray ( new String [ ] { } ) ) ; } return writer . toString ( ) ; } catch ( IOException e ) { return null ; } }
Converts the results to CSV data .
21,586
protected String getBasePath ( String rootPath ) { if ( rootPath . endsWith ( INHERITANCE_CONFIG_FILE_NAME ) ) { return rootPath . substring ( 0 , rootPath . length ( ) - INHERITANCE_CONFIG_FILE_NAME . length ( ) ) ; } return rootPath ; }
Returns the base path for a given configuration file .
21,587
public static String getStringOption ( Map < String , String > configOptions , String optionKey , String defaultValue ) { String result = configOptions . get ( optionKey ) ; return null != result ? result : defaultValue ; }
Returns the value of an option or the default if the value is null or the key is not part of the map .
21,588
private String generateValue ( ) { String result = "" ; for ( CmsCheckBox checkbox : m_checkboxes ) { if ( checkbox . isChecked ( ) ) { result += checkbox . getInternalValue ( ) + "," ; } } if ( result . contains ( "," ) ) { result = result . substring ( 0 , result . lastIndexOf ( "," ) ) ; } return result ; }
Generate a string with all selected checkboxes separated with .
21,589
protected void runQuery ( ) { String pool = m_pool . getValue ( ) ; String stmt = m_script . getValue ( ) ; if ( stmt . trim ( ) . isEmpty ( ) ) { return ; } CmsStringBufferReport report = new CmsStringBufferReport ( Locale . ENGLISH ) ; List < Throwable > errors = new ArrayList < > ( ) ; CmsSqlConsoleResults result = m_console . execute ( stmt , pool , report , errors ) ; if ( errors . size ( ) > 0 ) { CmsErrorDialog . showErrorDialog ( report . toString ( ) + errors . get ( 0 ) . getMessage ( ) , errors . get ( 0 ) ) ; } else { Window window = CmsBasicDialog . prepareWindow ( DialogWidth . max ) ; window . setCaption ( CmsVaadinUtils . getMessageText ( Messages . GUI_SQLCONSOLE_QUERY_RESULTS_0 ) ) ; window . setContent ( new CmsSqlConsoleResultsForm ( result , report . toString ( ) ) ) ; A_CmsUI . get ( ) . addWindow ( window ) ; window . center ( ) ; } }
Runs the currently entered query and displays the results .
21,590
public static Resource getSetupPage ( I_SetupUiContext context , String name ) { String path = CmsStringUtil . joinPaths ( context . getSetupBean ( ) . getContextPath ( ) , CmsSetupBean . FOLDER_SETUP , name ) ; Resource resource = new ExternalResource ( path ) ; return resource ; }
Gets external resource for an HTML page in the setup - resources folder .
21,591
protected void showStep ( A_CmsSetupStep step ) { Window window = newWindow ( ) ; window . setContent ( step ) ; window . setCaption ( step . getTitle ( ) ) ; A_CmsUI . get ( ) . addWindow ( window ) ; window . center ( ) ; }
Shows the given step .
21,592
protected void updateStep ( int stepNo ) { if ( ( 0 <= stepNo ) && ( stepNo < m_steps . size ( ) ) ) { Class < ? extends A_CmsSetupStep > cls = m_steps . get ( stepNo ) ; A_CmsSetupStep step ; try { step = cls . getConstructor ( I_SetupUiContext . class ) . newInstance ( this ) ; showStep ( step ) ; m_stepNo = stepNo ; } catch ( Exception e ) { CmsSetupErrorDialog . showErrorDialog ( e ) ; } } }
Moves to the step with the given number .
21,593
protected void appendFacetOption ( StringBuffer query , final String name , final String value ) { query . append ( " facet." ) . append ( name ) . append ( "=" ) . append ( value ) ; }
Appends the query part for the facet to the query string .
21,594
public void setEditedFilePath ( final String editedFilePath ) { m_filePathField . setReadOnly ( false ) ; m_filePathField . setValue ( editedFilePath ) ; m_filePathField . setReadOnly ( true ) ; }
Sets the path of the edited file in the corresponding display .
21,595
public void updateShownOptions ( boolean showModeSwitch , boolean showAddKeyOption ) { if ( showModeSwitch != m_showModeSwitch ) { m_upperLeftComponent . removeAllComponents ( ) ; m_upperLeftComponent . addComponent ( m_languageSwitch ) ; if ( showModeSwitch ) { m_upperLeftComponent . addComponent ( m_modeSwitch ) ; } m_upperLeftComponent . addComponent ( m_filePathLabel ) ; m_showModeSwitch = showModeSwitch ; } if ( showAddKeyOption != m_showAddKeyOption ) { if ( showAddKeyOption ) { m_optionsComponent . addComponent ( m_lowerLeftComponent , 0 , 1 ) ; m_optionsComponent . addComponent ( m_lowerRightComponent , 1 , 1 ) ; } else { m_optionsComponent . removeComponent ( 0 , 1 ) ; m_optionsComponent . removeComponent ( 1 , 1 ) ; } m_showAddKeyOption = showAddKeyOption ; } }
Update which options are shown .
21,596
void handleAddKey ( ) { String key = m_addKeyInput . getValue ( ) ; if ( m_listener . handleAddKey ( key ) ) { Notification . show ( key . isEmpty ( ) ? m_messages . key ( Messages . GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_EMPTY_KEY_SUCCESSFULLY_ADDED_0 ) : m_messages . key ( Messages . GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_KEY_SUCCESSFULLY_ADDED_1 , key ) ) ; } else { CmsMessageBundleEditorTypes . showWarning ( m_messages . key ( Messages . GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_KEY_ALREADEY_EXISTS_CAPTION_0 ) , m_messages . key ( Messages . GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_KEY_ALREADEY_EXISTS_DESCRIPTION_1 , key ) ) ; } m_addKeyInput . focus ( ) ; m_addKeyInput . selectAll ( ) ; }
Handles adding a key . Calls the registered listener and wraps it s method in some GUI adjustments .
21,597
void setLanguage ( final Locale locale ) { if ( ! m_languageSelect . getValue ( ) . equals ( locale ) ) { m_languageSelect . setValue ( locale ) ; } }
Sets the currently edited locale .
21,598
private Component createAddKeyButton ( ) { Button addKeyButton = new Button ( ) ; addKeyButton . addStyleName ( "icon-only" ) ; addKeyButton . addStyleName ( "borderless-colored" ) ; addKeyButton . setDescription ( m_messages . key ( Messages . GUI_ADD_KEY_0 ) ) ; addKeyButton . setIcon ( FontOpenCms . CIRCLE_PLUS , m_messages . key ( Messages . GUI_ADD_KEY_0 ) ) ; addKeyButton . addClickListener ( new ClickListener ( ) { private static final long serialVersionUID = 1L ; public void buttonClick ( ClickEvent event ) { handleAddKey ( ) ; } } ) ; return addKeyButton ; }
Creates the Add key button .
21,599
private void initModeSwitch ( final EditMode current ) { FormLayout modes = new FormLayout ( ) ; modes . setHeight ( "100%" ) ; modes . setDefaultComponentAlignment ( Alignment . MIDDLE_LEFT ) ; m_modeSelect = new ComboBox ( ) ; m_modeSelect . setCaption ( m_messages . key ( Messages . GUI_VIEW_SWITCHER_LABEL_0 ) ) ; m_modeSelect . addItem ( CmsMessageBundleEditorTypes . EditMode . DEFAULT ) ; m_modeSelect . setItemCaption ( CmsMessageBundleEditorTypes . EditMode . DEFAULT , m_messages . key ( Messages . GUI_VIEW_SWITCHER_EDITMODE_DEFAULT_0 ) ) ; m_modeSelect . addItem ( CmsMessageBundleEditorTypes . EditMode . MASTER ) ; m_modeSelect . setItemCaption ( CmsMessageBundleEditorTypes . EditMode . MASTER , m_messages . key ( Messages . GUI_VIEW_SWITCHER_EDITMODE_MASTER_0 ) ) ; m_modeSelect . setValue ( current ) ; m_modeSelect . setNewItemsAllowed ( false ) ; m_modeSelect . setTextInputAllowed ( false ) ; m_modeSelect . setNullSelectionAllowed ( false ) ; m_modeSelect . addValueChangeListener ( new ValueChangeListener ( ) { private static final long serialVersionUID = 1L ; public void valueChange ( ValueChangeEvent event ) { m_listener . handleModeChange ( ( EditMode ) event . getProperty ( ) . getValue ( ) ) ; } } ) ; modes . addComponent ( m_modeSelect ) ; m_modeSwitch = modes ; }
Initializes the mode switcher .