_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q1700
CmsCmisUtil.millisToCalendar
train
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; }
java
{ "resource": "" }
q1701
CmsTextArea.updateGhostStyle
train
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); } }
java
{ "resource": "" }
q1702
CmsCategoryWidget.generateCommonConfigPart
train
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; }
java
{ "resource": "" }
q1703
CmsImportExportManager.getDefaultTimestampModes
train
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; }
java
{ "resource": "" }
q1704
CmsValidationHandler.addHandler
train
protected <H extends EventHandler> HandlerRegistration addHandler(final H handler, GwtEvent.Type<H> type) { return ensureHandlers().addHandlerToSource(type, this, handler); }
java
{ "resource": "" }
q1705
CmsXMLSearchConfigurationParser.parseFacetQueryItems
train
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; } }
java
{ "resource": "" }
q1706
CmsXMLSearchConfigurationParser.parseFieldFacet
train
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; } }
java
{ "resource": "" }
q1707
CmsXMLSearchConfigurationParser.parseOptionalBooleanValue
train
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; } } }
java
{ "resource": "" }
q1708
CmsXMLSearchConfigurationParser.parseOptionalIntValue
train
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; } } }
java
{ "resource": "" }
q1709
CmsXMLSearchConfigurationParser.parseOptionalStringValue
train
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); } }
java
{ "resource": "" }
q1710
CmsXMLSearchConfigurationParser.parseOptionalStringValues
train
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; } }
java
{ "resource": "" }
q1711
CmsXMLSearchConfigurationParser.parseRangeFacet
train
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; } }
java
{ "resource": "" }
q1712
CmsXMLSearchConfigurationParser.getPageSizes
train
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; }
java
{ "resource": "" }
q1713
CmsXMLSearchConfigurationParser.getQueryParam
train
private String getQueryParam() { final String param = parseOptionalStringValue(XML_ELEMENT_QUERYPARAM); if (param == null) { return DEFAULT_QUERY_PARAM; } else { return param; } }
java
{ "resource": "" }
q1714
CmsXMLSearchConfigurationParser.getSortOptions
train
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; } }
java
{ "resource": "" }
q1715
CmsXMLSearchConfigurationParser.parseFacetQueryItem
train
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; } }
java
{ "resource": "" }
q1716
CmsXMLSearchConfigurationParser.parseMandatoryStringValue
train
private String parseMandatoryStringValue(final String path) throws Exception { final String value = parseOptionalStringValue(path); if (value == null) { throw new Exception(); } return value; }
java
{ "resource": "" }
q1717
CmsIndexingThread.createDefaultIndexDocument
train
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; } }
java
{ "resource": "" }
q1718
A_CmsJspValueWrapper.getToInstanceDate
train
public CmsJspInstanceDateBean getToInstanceDate() { if (m_instanceDate == null) { m_instanceDate = new CmsJspInstanceDateBean(getToDate(), m_cms.getRequestContext().getLocale()); } return m_instanceDate; }
java
{ "resource": "" }
q1719
Messages.getGalleryNotFoundKey
train
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(); }
java
{ "resource": "" }
q1720
Messages.getTitleGalleryKey
train
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(); }
java
{ "resource": "" }
q1721
CmsTemplateMapper.getTemplateMapperConfig
train
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; }
java
{ "resource": "" }
q1722
CmsTemplateMapper.getConfiguration
train
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 } } })); }
java
{ "resource": "" }
q1723
CmsErrorDialog.onShow
train
private void onShow() { if (m_detailsFieldset != null) { m_detailsFieldset.getContentPanel().getElement().getStyle().setPropertyPx( "maxHeight", getAvailableHeight(m_messageWidget.getOffsetHeight())); } }
java
{ "resource": "" }
q1724
CmsGitCheckin.addModuleToExport
train
public void addModuleToExport(final String moduleName) { if (m_modulesToExport == null) { m_modulesToExport = new HashSet<String>(); } m_modulesToExport.add(moduleName); }
java
{ "resource": "" }
q1725
CmsGitCheckin.checkIn
train
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; } }
java
{ "resource": "" }
q1726
CmsGitCheckin.setCurrentConfiguration
train
public boolean setCurrentConfiguration(CmsGitConfiguration configuration) { if ((null != configuration) && configuration.isValid()) { m_currentConfiguration = configuration; return true; } return false; }
java
{ "resource": "" }
q1727
CmsGitCheckin.checkInInternal
train
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; }
java
{ "resource": "" }
q1728
CmsGitCheckin.checkinScriptCommand
train
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 + "\""; }
java
{ "resource": "" }
q1729
CmsGitCheckin.exportModules
train
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); } } } }
java
{ "resource": "" }
q1730
CmsGitCheckin.readConfigFiles
train
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; }
java
{ "resource": "" }
q1731
CmsGitCheckin.runCommitScript
train
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; } }
java
{ "resource": "" }
q1732
CmsGitToolOptionsPanel.updateForNewConfiguration
train
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())); }
java
{ "resource": "" }
q1733
CmsGitToolOptionsPanel.configureConfigurationSelector
train
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(); } }); } }
java
{ "resource": "" }
q1734
CmsStylesheetLoader.loadWithTimeout
train
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); } }
java
{ "resource": "" }
q1735
CmsSolrIndex.hasPermissions
train
protected boolean hasPermissions(CmsObject cms, CmsSolrDocument doc, CmsResourceFilter filter) { return null != (filter == null ? getResource(cms, doc) : getResource(cms, doc, filter)); }
java
{ "resource": "" }
q1736
CmsSolrIndex.isDebug
train
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; }
java
{ "resource": "" }
q1737
CmsSolrIndex.throwExceptionIfSafetyRestrictionsAreViolated
train
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))); } } } } } } }
java
{ "resource": "" }
q1738
CmsCloneModuleThread.alterPrefix
train
private String alterPrefix(String word, String oldPrefix, String newPrefix) { if (word.startsWith(oldPrefix)) { return word.replaceFirst(oldPrefix, newPrefix); } return (newPrefix + word); }
java
{ "resource": "" }
q1739
CmsSetupStep02ComponentCheck.updateColor
train
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; } }
java
{ "resource": "" }
q1740
CmsCategoryService.copyCategories
train
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); } }
java
{ "resource": "" }
q1741
CmsJspTagBundle.getLocale
train
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; }
java
{ "resource": "" }
q1742
CmsDefaultLinkSubstitutionHandler.generateCacheKey
train
protected String generateCacheKey( CmsObject cms, String targetSiteRoot, String detailPagePart, String absoluteLink) { return cms.getRequestContext().getSiteRoot() + ":" + targetSiteRoot + ":" + detailPagePart + absoluteLink; }
java
{ "resource": "" }
q1743
CmsDefaultLinkSubstitutionHandler.isSecureLink
train
protected boolean isSecureLink(CmsObject cms, String vfsName, CmsSite targetSite, boolean secureRequest) { return OpenCms.getStaticExportManager().isSecureLink(cms, vfsName, targetSite.getSiteRoot(), secureRequest); }
java
{ "resource": "" }
q1744
CmsColor.MIN
train
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; }
java
{ "resource": "" }
q1745
CmsColor.setHex
train
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; }
java
{ "resource": "" }
q1746
CmsSerialDateService.formatDate
train
private String formatDate(Date date) { if (null == m_dateFormat) { m_dateFormat = DateFormat.getDateInstance( 0, OpenCms.getWorkplaceManager().getWorkplaceLocale(getCmsObject())); } return m_dateFormat.format(date); }
java
{ "resource": "" }
q1747
CmsJspTagEdit.createResource
train
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); }
java
{ "resource": "" }
q1748
CmsResourceBundleLoader.tryBundle
train
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; }
java
{ "resource": "" }
q1749
CmsResourceBundleLoader.tryBundle
train
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; }
java
{ "resource": "" }
q1750
CmsSerialDateValue.validateWithMessage
train
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; }
java
{ "resource": "" }
q1751
CmsSerialDateValue.datesToJson
train
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; }
java
{ "resource": "" }
q1752
CmsSerialDateValue.readOptionalArray
train
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; }
java
{ "resource": "" }
q1753
CmsSerialDateValue.readOptionalBoolean
train
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; }
java
{ "resource": "" }
q1754
CmsSerialDateValue.readOptionalString
train
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; }
java
{ "resource": "" }
q1755
CmsSerialDateValue.readPattern
train
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)); }
java
{ "resource": "" }
q1756
CmsSerialDateValue.toJsonStringArray
train
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; } }
java
{ "resource": "" }
q1757
CmsSerialDateValue.validateDuration
train
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; } }
java
{ "resource": "" }
q1758
CmsSerialDateValue.validatePattern
train
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; }
java
{ "resource": "" }
q1759
CmsDbPoolV11.createHikariConfig
train
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; }
java
{ "resource": "" }
q1760
CmsUgcSession.unmarshalXmlContent
train
private CmsXmlContent unmarshalXmlContent(CmsFile file) throws CmsXmlException { CmsXmlContent content = CmsXmlContentFactory.unmarshal(m_cms, file); content.setAutoCorrectionEnabled(true); content.correctXmlStructure(m_cms); return content; }
java
{ "resource": "" }
q1761
A_CmsImport.getImportAccessControlEntry
train
protected CmsAccessControlEntry getImportAccessControlEntry( CmsResource res, String id, String allowed, String denied, String flags) { return new CmsAccessControlEntry( res.getResourceId(), new CmsUUID(id), Integer.parseInt(allowed), Integer.parseInt(denied), Integer.parseInt(flags)); }
java
{ "resource": "" }
q1762
Messages.getStateKey
train
public static String getStateKey(CmsResourceState state) { StringBuffer sb = new StringBuffer(STATE_PREFIX); sb.append(state); sb.append(STATE_POSTFIX); return sb.toString(); }
java
{ "resource": "" }
q1763
CmsAppViewLayout.createPublishButton
train
public static Button createPublishButton(final I_CmsUpdateListener<String> updateListener) { Button publishButton = CmsToolBar.createButton( FontOpenCms.PUBLISH, CmsVaadinUtils.getMessageText(Messages.GUI_PUBLISH_BUTTON_TITLE_0)); if (CmsAppWorkplaceUi.isOnlineProject()) { // disable publishing in online project publishButton.setEnabled(false); publishButton.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_TOOLBAR_NOT_AVAILABLE_ONLINE_0)); } publishButton.addClickListener(new ClickListener() { /** Serial version id. */ private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { CmsAppWorkplaceUi.get().disableGlobalShortcuts(); CmsGwtDialogExtension extension = new CmsGwtDialogExtension(A_CmsUI.get(), updateListener); extension.openPublishDialog(); } }); return publishButton; }
java
{ "resource": "" }
q1764
CmsMessageBundleEditor.getFilters
train
Map<Object, Object> getFilters() { Map<Object, Object> result = new HashMap<Object, Object>(4); result.put(TableProperty.KEY, m_table.getFilterFieldValue(TableProperty.KEY)); result.put(TableProperty.DEFAULT, m_table.getFilterFieldValue(TableProperty.DEFAULT)); result.put(TableProperty.DESCRIPTION, m_table.getFilterFieldValue(TableProperty.DESCRIPTION)); result.put(TableProperty.TRANSLATION, m_table.getFilterFieldValue(TableProperty.TRANSLATION)); return result; }
java
{ "resource": "" }
q1765
CmsMessageBundleEditor.saveAction
train
void saveAction() { Map<Object, Object> filters = getFilters(); m_table.clearFilters(); try { m_model.save(); disableSaveButtons(); } catch (CmsException e) { LOG.error(m_messages.key(Messages.ERR_SAVING_CHANGES_0), e); CmsErrorDialog.showErrorDialog(m_messages.key(Messages.ERR_SAVING_CHANGES_0), e); } setFilters(filters); }
java
{ "resource": "" }
q1766
CmsMessageBundleEditor.setFilters
train
void setFilters(Map<Object, Object> filters) { for (Object column : filters.keySet()) { Object filterValue = filters.get(column); if ((filterValue != null) && !filterValue.toString().isEmpty() && !m_table.isColumnCollapsed(column)) { m_table.setFilterFieldValue(column, filterValue); } } }
java
{ "resource": "" }
q1767
CmsMessageBundleEditor.adjustOptionsColumn
train
private void adjustOptionsColumn( CmsMessageBundleEditorTypes.EditMode oldMode, CmsMessageBundleEditorTypes.EditMode newMode) { if (m_model.isShowOptionsColumn(oldMode) != m_model.isShowOptionsColumn(newMode)) { m_table.removeGeneratedColumn(TableProperty.OPTIONS); if (m_model.isShowOptionsColumn(newMode)) { // Don't know why exactly setting the filter field invisible is necessary here, // it should be already set invisible - but apparently not setting it invisible again // will result in the field being visible. m_table.setFilterFieldVisible(TableProperty.OPTIONS, false); m_table.addGeneratedColumn(TableProperty.OPTIONS, m_optionsColumn); } } }
java
{ "resource": "" }
q1768
CmsMessageBundleEditor.adjustVisibleColumns
train
private void adjustVisibleColumns() { if (m_table.isColumnCollapsingAllowed()) { if ((m_model.hasDefaultValues()) || m_model.getBundleType().equals(BundleType.DESCRIPTOR)) { m_table.setColumnCollapsed(TableProperty.DEFAULT, false); } else { m_table.setColumnCollapsed(TableProperty.DEFAULT, true); } if (((m_model.getEditMode().equals(EditMode.MASTER) || m_model.hasDescriptionValues())) || m_model.getBundleType().equals(BundleType.DESCRIPTOR)) { m_table.setColumnCollapsed(TableProperty.DESCRIPTION, false); } else { m_table.setColumnCollapsed(TableProperty.DESCRIPTION, true); } } }
java
{ "resource": "" }
q1769
CmsMessageBundleEditor.cleanUpAction
train
private void cleanUpAction() { try { m_model.deleteDescriptorIfNecessary(); } catch (CmsException e) { LOG.error(m_messages.key(Messages.ERR_DELETING_DESCRIPTOR_0), e); } // unlock resource m_model.unlock(); }
java
{ "resource": "" }
q1770
CmsMessageBundleEditor.createAddDescriptorButton
train
@SuppressWarnings("serial") private Component createAddDescriptorButton() { Button addDescriptorButton = CmsToolBar.createButton( FontOpenCms.COPY_LOCALE, m_messages.key(Messages.GUI_ADD_DESCRIPTOR_0)); addDescriptorButton.setDisableOnClick(true); addDescriptorButton.addClickListener(new ClickListener() { @SuppressWarnings("synthetic-access") public void buttonClick(ClickEvent event) { Map<Object, Object> filters = getFilters(); m_table.clearFilters(); if (!m_model.addDescriptor()) { CmsVaadinUtils.showAlert( m_messages.key(Messages.ERR_BUNDLE_DESCRIPTOR_CREATION_FAILED_0), m_messages.key(Messages.ERR_BUNDLE_DESCRIPTOR_CREATION_FAILED_DESCRIPTION_0), null); } else { IndexedContainer newContainer = null; try { newContainer = m_model.getContainerForCurrentLocale(); m_table.setContainerDataSource(newContainer); initFieldFactories(); initStyleGenerators(); setEditMode(EditMode.MASTER); m_table.setColumnCollapsingAllowed(true); adjustVisibleColumns(); m_options.updateShownOptions(m_model.hasMasterMode(), m_model.canAddKeys()); m_options.setEditMode(m_model.getEditMode()); } catch (IOException | CmsException e) { // Can never appear here, since container is created by addDescriptor already. LOG.error(e.getLocalizedMessage(), e); } } setFilters(filters); } }); return addDescriptorButton; }
java
{ "resource": "" }
q1771
CmsMessageBundleEditor.createCloseButton
train
@SuppressWarnings("serial") private Component createCloseButton() { Button closeBtn = CmsToolBar.createButton( FontOpenCms.CIRCLE_INV_CANCEL, m_messages.key(Messages.GUI_BUTTON_CANCEL_0)); closeBtn.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { closeAction(); } }); return closeBtn; }
java
{ "resource": "" }
q1772
CmsMessageBundleEditor.createConvertToPropertyBundleButton
train
private Component createConvertToPropertyBundleButton() { Button addDescriptorButton = CmsToolBar.createButton( FontOpenCms.SETTINGS, m_messages.key(Messages.GUI_CONVERT_TO_PROPERTY_BUNDLE_0)); addDescriptorButton.setDisableOnClick(true); addDescriptorButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { try { m_model.saveAsPropertyBundle(); Notification.show("Conversion successful."); } catch (CmsException | IOException e) { CmsVaadinUtils.showAlert("Conversion failed", e.getLocalizedMessage(), null); } } }); addDescriptorButton.setDisableOnClick(true); return addDescriptorButton; }
java
{ "resource": "" }
q1773
CmsMessageBundleEditor.createMainComponent
train
private Component createMainComponent() throws IOException, CmsException { VerticalLayout mainComponent = new VerticalLayout(); mainComponent.setSizeFull(); mainComponent.addStyleName("o-message-bundle-editor"); m_table = createTable(); Panel navigator = new Panel(); navigator.setSizeFull(); navigator.setContent(m_table); navigator.addActionHandler(new CmsMessageBundleEditorTypes.TableKeyboardHandler(m_table)); navigator.addStyleName("v-panel-borderless"); mainComponent.addComponent(m_options.getOptionsComponent()); mainComponent.addComponent(navigator); mainComponent.setExpandRatio(navigator, 1f); m_options.updateShownOptions(m_model.hasMasterMode(), m_model.canAddKeys()); return mainComponent; }
java
{ "resource": "" }
q1774
CmsMessageBundleEditor.createSaveExitButton
train
@SuppressWarnings("serial") private Button createSaveExitButton() { Button saveExitBtn = CmsToolBar.createButton( FontOpenCms.SAVE_EXIT, m_messages.key(Messages.GUI_BUTTON_SAVE_AND_EXIT_0)); saveExitBtn.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { saveAction(); closeAction(); } }); saveExitBtn.setEnabled(false); return saveExitBtn; }
java
{ "resource": "" }
q1775
CmsMessageBundleEditor.fillToolBar
train
private void fillToolBar(final I_CmsAppUIContext context) { context.setAppTitle(m_messages.key(Messages.GUI_APP_TITLE_0)); // create components 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); } }
java
{ "resource": "" }
q1776
CmsMessageBundleEditor.handleChange
train
private void handleChange(Object propertyId) { if (!m_saveBtn.isEnabled()) { m_saveBtn.setEnabled(true); m_saveExitBtn.setEnabled(true); } m_model.handleChange(propertyId); }
java
{ "resource": "" }
q1777
CmsMessageBundleEditor.initFieldFactories
train
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); }
java
{ "resource": "" }
q1778
CmsMessageBundleEditor.initStyleGenerators
train
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))); }
java
{ "resource": "" }
q1779
CmsMessageBundleEditor.keyAlreadyExists
train
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; }
java
{ "resource": "" }
q1780
CmsUgcWrapper.uploadFields
train
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); // Using an array here because we can only store the handler registration after it has been created , but 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(); }
java
{ "resource": "" }
q1781
CmsJspElFunctions.convertResource
train
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; }
java
{ "resource": "" }
q1782
CmsJspElFunctions.convertResourceList
train
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; }
java
{ "resource": "" }
q1783
CmsSearchConfigurationPagination.create
train
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; }
java
{ "resource": "" }
q1784
CmsSearchUtil.getDateCreatedTimeRangeFilterQuery
train
public static String getDateCreatedTimeRangeFilterQuery(String searchField, long startTime, long endTime) { String sStartTime = null; String sEndTime = null; // Convert startTime to ISO 8601 format if ((startTime > Long.MIN_VALUE) && (startTime < Long.MAX_VALUE)) { sStartTime = CmsSearchUtil.getDateAsIso8601(new Date(startTime)); } // Convert endTime to ISO 8601 format if ((endTime > Long.MIN_VALUE) && (endTime < Long.MAX_VALUE)) { sEndTime = CmsSearchUtil.getDateAsIso8601(new Date(endTime)); } // Build Solr range string final String rangeString = CmsSearchUtil.getSolrRangeString(sStartTime, sEndTime); // Build Solr filter string return String.format("%s:%s", searchField, rangeString); }
java
{ "resource": "" }
q1785
CmsSearchUtil.getSolrRangeString
train
public static String getSolrRangeString(String from, String to) { // If a parameter is not initialized, use the asterisk '*' operator if (CmsStringUtil.isEmptyOrWhitespaceOnly(from)) { from = "*"; } if (CmsStringUtil.isEmptyOrWhitespaceOnly(to)) { to = "*"; } return String.format("[%s TO %s]", from, to); }
java
{ "resource": "" }
q1786
CmsSearchUtil.toContentStreams
train
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; }
java
{ "resource": "" }
q1787
CmsSearchStateParameters.paramMapToString
train
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('&'); } } } // remove last '&' if (result.length() > 0) { result.setLength(result.length() - 1); } return result.toString(); }
java
{ "resource": "" }
q1788
CmsSearchStateParameters.getFacetParamKey
train
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(); } // Facet did not exist LOG.warn(Messages.get().getBundle().key(Messages.LOG_FACET_NOT_CONFIGURED_1, facet), new Throwable()); return null; }
java
{ "resource": "" }
q1789
CmsVaadinUtils.closeWindow
train
public static void closeWindow(Component component) { Window window = getWindow(component); if (window != null) { window.close(); } }
java
{ "resource": "" }
q1790
CmsVaadinUtils.defaultHandleContextMenuForMultiselect
train
@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); } } }
java
{ "resource": "" }
q1791
CmsVaadinUtils.getGroupsOfUser
train
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; }
java
{ "resource": "" }
q1792
CmsVaadinUtils.getPrincipalContainer
train
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; }
java
{ "resource": "" }
q1793
CmsVaadinUtils.setFilterBoxStyle
train
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); }
java
{ "resource": "" }
q1794
CmsImportHelper.getZipEntry
train
protected ZipEntry getZipEntry(String filename) throws ZipException { // yes ZipEntry entry = getZipFile().getEntry(filename); // path to file might be relative, too 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; }
java
{ "resource": "" }
q1795
A_CmsNotification.appenHtmlFooter
train
protected void appenHtmlFooter(StringBuffer buffer) { if (m_configuredFooter != null) { buffer.append(m_configuredFooter); } else { buffer.append(" </body>\r\n" + "</html>"); } }
java
{ "resource": "" }
q1796
CmsModuleApp.openReport
train
public void openReport(String newState, A_CmsReportThread thread, String label) { setReport(newState, thread); m_labels.put(thread, label); openSubView(newState, true); }
java
{ "resource": "" }
q1797
CmsFavoriteEntry.readId
train
public static CmsUUID readId(JSONObject obj, String key) { String strValue = obj.optString(key); if (!CmsUUID.isValidUUID(strValue)) { return null; } return new CmsUUID(strValue); }
java
{ "resource": "" }
q1798
CmsFavoriteEntry.setSiteRoot
train
public void setSiteRoot(String siteRoot) { if (siteRoot != null) { siteRoot = siteRoot.replaceFirst("/$", ""); } m_siteRoot = siteRoot; }
java
{ "resource": "" }
q1799
CmsFavoriteEntry.toJson
train
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; }
java
{ "resource": "" }