repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
alkacon/opencms-core | src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java | CmsMessageBundleEditorModel.saveToPropertyVfsBundle | private void saveToPropertyVfsBundle() throws CmsException {
for (Locale l : m_changedTranslations) {
SortedProperties props = m_localizations.get(l);
LockedFile f = m_lockedBundleFiles.get(l);
if ((null != props) && (null != f)) {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Writer writer = new OutputStreamWriter(outputStream, f.getEncoding());
props.store(writer, null);
byte[] contentBytes = outputStream.toByteArray();
CmsFile file = f.getFile();
file.setContents(contentBytes);
String contentEncodingProperty = m_cms.readPropertyObject(
file,
CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING,
false).getValue();
if ((null == contentEncodingProperty) || !contentEncodingProperty.equals(f.getEncoding())) {
m_cms.writePropertyObject(
m_cms.getSitePath(file),
new CmsProperty(
CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING,
f.getEncoding(),
f.getEncoding()));
}
m_cms.writeFile(file);
} catch (IOException e) {
LOG.error(
Messages.get().getBundle().key(
Messages.ERR_READING_FILE_UNSUPPORTED_ENCODING_2,
f.getFile().getRootPath(),
f.getEncoding()),
e);
}
}
}
} | java | private void saveToPropertyVfsBundle() throws CmsException {
for (Locale l : m_changedTranslations) {
SortedProperties props = m_localizations.get(l);
LockedFile f = m_lockedBundleFiles.get(l);
if ((null != props) && (null != f)) {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Writer writer = new OutputStreamWriter(outputStream, f.getEncoding());
props.store(writer, null);
byte[] contentBytes = outputStream.toByteArray();
CmsFile file = f.getFile();
file.setContents(contentBytes);
String contentEncodingProperty = m_cms.readPropertyObject(
file,
CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING,
false).getValue();
if ((null == contentEncodingProperty) || !contentEncodingProperty.equals(f.getEncoding())) {
m_cms.writePropertyObject(
m_cms.getSitePath(file),
new CmsProperty(
CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING,
f.getEncoding(),
f.getEncoding()));
}
m_cms.writeFile(file);
} catch (IOException e) {
LOG.error(
Messages.get().getBundle().key(
Messages.ERR_READING_FILE_UNSUPPORTED_ENCODING_2,
f.getFile().getRootPath(),
f.getEncoding()),
e);
}
}
}
} | [
"private",
"void",
"saveToPropertyVfsBundle",
"(",
")",
"throws",
"CmsException",
"{",
"for",
"(",
"Locale",
"l",
":",
"m_changedTranslations",
")",
"{",
"SortedProperties",
"props",
"=",
"m_localizations",
".",
"get",
"(",
"l",
")",
";",
"LockedFile",
"f",
"=... | Saves messages to a propertyvfsbundle file.
@throws CmsException thrown if writing to the file fails. | [
"Saves",
"messages",
"to",
"a",
"propertyvfsbundle",
"file",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java#L1830-L1867 | train |
alkacon/opencms-core | src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java | CmsMessageBundleEditorModel.saveToXmlVfsBundle | private void saveToXmlVfsBundle() throws CmsException {
if (m_lockedBundleFiles.get(null) != null) { // If the file was not locked, no changes were made, i.e., storing is not necessary.
for (Locale l : m_locales) {
SortedProperties props = m_localizations.get(l);
if (null != props) {
if (m_xmlBundle.hasLocale(l)) {
m_xmlBundle.removeLocale(l);
}
m_xmlBundle.addLocale(m_cms, l);
int i = 0;
List<Object> keys = new ArrayList<Object>(props.keySet());
Collections.sort(keys, CmsCaseInsensitiveStringComparator.getInstance());
for (Object key : keys) {
if ((null != key) && !key.toString().isEmpty()) {
String value = props.getProperty(key.toString());
if (!value.isEmpty()) {
m_xmlBundle.addValue(m_cms, "Message", l, i);
i++;
m_xmlBundle.getValue("Message[" + i + "]/Key", l).setStringValue(m_cms, key.toString());
m_xmlBundle.getValue("Message[" + i + "]/Value", l).setStringValue(m_cms, value);
}
}
}
}
CmsFile bundleFile = m_lockedBundleFiles.get(null).getFile();
bundleFile.setContents(m_xmlBundle.marshal());
m_cms.writeFile(bundleFile);
}
}
} | java | private void saveToXmlVfsBundle() throws CmsException {
if (m_lockedBundleFiles.get(null) != null) { // If the file was not locked, no changes were made, i.e., storing is not necessary.
for (Locale l : m_locales) {
SortedProperties props = m_localizations.get(l);
if (null != props) {
if (m_xmlBundle.hasLocale(l)) {
m_xmlBundle.removeLocale(l);
}
m_xmlBundle.addLocale(m_cms, l);
int i = 0;
List<Object> keys = new ArrayList<Object>(props.keySet());
Collections.sort(keys, CmsCaseInsensitiveStringComparator.getInstance());
for (Object key : keys) {
if ((null != key) && !key.toString().isEmpty()) {
String value = props.getProperty(key.toString());
if (!value.isEmpty()) {
m_xmlBundle.addValue(m_cms, "Message", l, i);
i++;
m_xmlBundle.getValue("Message[" + i + "]/Key", l).setStringValue(m_cms, key.toString());
m_xmlBundle.getValue("Message[" + i + "]/Value", l).setStringValue(m_cms, value);
}
}
}
}
CmsFile bundleFile = m_lockedBundleFiles.get(null).getFile();
bundleFile.setContents(m_xmlBundle.marshal());
m_cms.writeFile(bundleFile);
}
}
} | [
"private",
"void",
"saveToXmlVfsBundle",
"(",
")",
"throws",
"CmsException",
"{",
"if",
"(",
"m_lockedBundleFiles",
".",
"get",
"(",
"null",
")",
"!=",
"null",
")",
"{",
"// If the file was not locked, no changes were made, i.e., storing is not necessary.",
"for",
"(",
... | Saves messages to a xmlvfsbundle file.
@throws CmsException thrown if writing to the file fails. | [
"Saves",
"messages",
"to",
"a",
"xmlvfsbundle",
"file",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java#L1874-L1904 | train |
alkacon/opencms-core | src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java | CmsMessageBundleEditorModel.setResourceInformation | private void setResourceInformation() {
String sitePath = m_cms.getSitePath(m_resource);
int pathEnd = sitePath.lastIndexOf('/') + 1;
String baseName = sitePath.substring(pathEnd);
m_sitepath = sitePath.substring(0, pathEnd);
switch (CmsMessageBundleEditorTypes.BundleType.toBundleType(
OpenCms.getResourceManager().getResourceType(m_resource).getTypeName())) {
case PROPERTY:
String localeSuffix = CmsStringUtil.getLocaleSuffixForName(baseName);
if ((null != localeSuffix) && !localeSuffix.isEmpty()) {
baseName = baseName.substring(
0,
baseName.lastIndexOf(localeSuffix) - (1 /* cut off trailing underscore, too*/));
m_locale = CmsLocaleManager.getLocale(localeSuffix);
}
if ((null == m_locale) || !m_locales.contains(m_locale)) {
m_switchedLocaleOnOpening = true;
m_locale = m_locales.iterator().next();
}
break;
case XML:
m_locale = OpenCms.getLocaleManager().getBestAvailableLocaleForXmlContent(
m_cms,
m_resource,
m_xmlBundle);
break;
case DESCRIPTOR:
m_basename = baseName.substring(
0,
baseName.length() - CmsMessageBundleEditorTypes.Descriptor.POSTFIX.length());
m_locale = new Locale("en");
break;
default:
throw new IllegalArgumentException(
Messages.get().container(
Messages.ERR_UNSUPPORTED_BUNDLE_TYPE_1,
CmsMessageBundleEditorTypes.BundleType.toBundleType(
OpenCms.getResourceManager().getResourceType(m_resource).getTypeName())).toString());
}
m_basename = baseName;
} | java | private void setResourceInformation() {
String sitePath = m_cms.getSitePath(m_resource);
int pathEnd = sitePath.lastIndexOf('/') + 1;
String baseName = sitePath.substring(pathEnd);
m_sitepath = sitePath.substring(0, pathEnd);
switch (CmsMessageBundleEditorTypes.BundleType.toBundleType(
OpenCms.getResourceManager().getResourceType(m_resource).getTypeName())) {
case PROPERTY:
String localeSuffix = CmsStringUtil.getLocaleSuffixForName(baseName);
if ((null != localeSuffix) && !localeSuffix.isEmpty()) {
baseName = baseName.substring(
0,
baseName.lastIndexOf(localeSuffix) - (1 /* cut off trailing underscore, too*/));
m_locale = CmsLocaleManager.getLocale(localeSuffix);
}
if ((null == m_locale) || !m_locales.contains(m_locale)) {
m_switchedLocaleOnOpening = true;
m_locale = m_locales.iterator().next();
}
break;
case XML:
m_locale = OpenCms.getLocaleManager().getBestAvailableLocaleForXmlContent(
m_cms,
m_resource,
m_xmlBundle);
break;
case DESCRIPTOR:
m_basename = baseName.substring(
0,
baseName.length() - CmsMessageBundleEditorTypes.Descriptor.POSTFIX.length());
m_locale = new Locale("en");
break;
default:
throw new IllegalArgumentException(
Messages.get().container(
Messages.ERR_UNSUPPORTED_BUNDLE_TYPE_1,
CmsMessageBundleEditorTypes.BundleType.toBundleType(
OpenCms.getResourceManager().getResourceType(m_resource).getTypeName())).toString());
}
m_basename = baseName;
} | [
"private",
"void",
"setResourceInformation",
"(",
")",
"{",
"String",
"sitePath",
"=",
"m_cms",
".",
"getSitePath",
"(",
"m_resource",
")",
";",
"int",
"pathEnd",
"=",
"sitePath",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
";",
"String",
"baseName",... | Extract site path, base name and locale from the resource opened with the editor. | [
"Extract",
"site",
"path",
"base",
"name",
"and",
"locale",
"from",
"the",
"resource",
"opened",
"with",
"the",
"editor",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java#L1907-L1949 | train |
alkacon/opencms-core | src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java | CmsMessageBundleEditorModel.unmarshalDescriptor | private void unmarshalDescriptor() throws CmsXmlException, CmsException {
if (null != m_desc) {
// unmarshal descriptor
m_descContent = CmsXmlContentFactory.unmarshal(m_cms, m_cms.readFile(m_desc));
// configure messages if wanted
CmsProperty bundleProp = m_cms.readPropertyObject(m_desc, PROPERTY_BUNDLE_DESCRIPTOR_LOCALIZATION, true);
if (!(bundleProp.isNullProperty() || bundleProp.getValue().trim().isEmpty())) {
m_configuredBundle = bundleProp.getValue();
}
}
} | java | private void unmarshalDescriptor() throws CmsXmlException, CmsException {
if (null != m_desc) {
// unmarshal descriptor
m_descContent = CmsXmlContentFactory.unmarshal(m_cms, m_cms.readFile(m_desc));
// configure messages if wanted
CmsProperty bundleProp = m_cms.readPropertyObject(m_desc, PROPERTY_BUNDLE_DESCRIPTOR_LOCALIZATION, true);
if (!(bundleProp.isNullProperty() || bundleProp.getValue().trim().isEmpty())) {
m_configuredBundle = bundleProp.getValue();
}
}
} | [
"private",
"void",
"unmarshalDescriptor",
"(",
")",
"throws",
"CmsXmlException",
",",
"CmsException",
"{",
"if",
"(",
"null",
"!=",
"m_desc",
")",
"{",
"// unmarshal descriptor",
"m_descContent",
"=",
"CmsXmlContentFactory",
".",
"unmarshal",
"(",
"m_cms",
",",
"m... | Unmarshals the descriptor content.
@throws CmsXmlException thrown if the XML structure of the descriptor is wrong.
@throws CmsException thrown if reading the descriptor file fails. | [
"Unmarshals",
"the",
"descriptor",
"content",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java#L1957-L1971 | train |
alkacon/opencms-core | src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java | CmsMessageBundleEditorModel.updateBundleDescriptorContent | private void updateBundleDescriptorContent() throws CmsXmlException {
if (m_descContent.hasLocale(Descriptor.LOCALE)) {
m_descContent.removeLocale(Descriptor.LOCALE);
}
m_descContent.addLocale(m_cms, Descriptor.LOCALE);
int i = 0;
Property<Object> descProp;
String desc;
Property<Object> defaultValueProp;
String defaultValue;
Map<String, Item> keyItemMap = getKeyItemMap();
List<String> keys = new ArrayList<String>(keyItemMap.keySet());
Collections.sort(keys, CmsCaseInsensitiveStringComparator.getInstance());
for (Object key : keys) {
if ((null != key) && !key.toString().isEmpty()) {
m_descContent.addValue(m_cms, Descriptor.N_MESSAGE, Descriptor.LOCALE, i);
i++;
String messagePrefix = Descriptor.N_MESSAGE + "[" + i + "]/";
m_descContent.getValue(messagePrefix + Descriptor.N_KEY, Descriptor.LOCALE).setStringValue(
m_cms,
(String)key);
descProp = keyItemMap.get(key).getItemProperty(TableProperty.DESCRIPTION);
if ((null != descProp) && (null != descProp.getValue())) {
desc = descProp.getValue().toString();
m_descContent.getValue(messagePrefix + Descriptor.N_DESCRIPTION, Descriptor.LOCALE).setStringValue(
m_cms,
desc);
}
defaultValueProp = keyItemMap.get(key).getItemProperty(TableProperty.DEFAULT);
if ((null != defaultValueProp) && (null != defaultValueProp.getValue())) {
defaultValue = defaultValueProp.getValue().toString();
m_descContent.getValue(messagePrefix + Descriptor.N_DEFAULT, Descriptor.LOCALE).setStringValue(
m_cms,
defaultValue);
}
}
}
} | java | private void updateBundleDescriptorContent() throws CmsXmlException {
if (m_descContent.hasLocale(Descriptor.LOCALE)) {
m_descContent.removeLocale(Descriptor.LOCALE);
}
m_descContent.addLocale(m_cms, Descriptor.LOCALE);
int i = 0;
Property<Object> descProp;
String desc;
Property<Object> defaultValueProp;
String defaultValue;
Map<String, Item> keyItemMap = getKeyItemMap();
List<String> keys = new ArrayList<String>(keyItemMap.keySet());
Collections.sort(keys, CmsCaseInsensitiveStringComparator.getInstance());
for (Object key : keys) {
if ((null != key) && !key.toString().isEmpty()) {
m_descContent.addValue(m_cms, Descriptor.N_MESSAGE, Descriptor.LOCALE, i);
i++;
String messagePrefix = Descriptor.N_MESSAGE + "[" + i + "]/";
m_descContent.getValue(messagePrefix + Descriptor.N_KEY, Descriptor.LOCALE).setStringValue(
m_cms,
(String)key);
descProp = keyItemMap.get(key).getItemProperty(TableProperty.DESCRIPTION);
if ((null != descProp) && (null != descProp.getValue())) {
desc = descProp.getValue().toString();
m_descContent.getValue(messagePrefix + Descriptor.N_DESCRIPTION, Descriptor.LOCALE).setStringValue(
m_cms,
desc);
}
defaultValueProp = keyItemMap.get(key).getItemProperty(TableProperty.DEFAULT);
if ((null != defaultValueProp) && (null != defaultValueProp.getValue())) {
defaultValue = defaultValueProp.getValue().toString();
m_descContent.getValue(messagePrefix + Descriptor.N_DEFAULT, Descriptor.LOCALE).setStringValue(
m_cms,
defaultValue);
}
}
}
} | [
"private",
"void",
"updateBundleDescriptorContent",
"(",
")",
"throws",
"CmsXmlException",
"{",
"if",
"(",
"m_descContent",
".",
"hasLocale",
"(",
"Descriptor",
".",
"LOCALE",
")",
")",
"{",
"m_descContent",
".",
"removeLocale",
"(",
"Descriptor",
".",
"LOCALE",
... | Update the descriptor content with values from the editor.
@throws CmsXmlException thrown if update fails due to a wrong XML structure (should never happen) | [
"Update",
"the",
"descriptor",
"content",
"with",
"values",
"from",
"the",
"editor",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java#L1977-L2021 | train |
alkacon/opencms-core | src-gwt/org/opencms/ade/sitemap/client/CmsSitemapTreeItem.java | CmsSitemapTreeItem.removeInvalidChildren | protected void removeInvalidChildren() {
if (getLoadState() == LoadState.LOADED) {
List<CmsSitemapTreeItem> toDelete = new ArrayList<CmsSitemapTreeItem>();
for (int i = 0; i < getChildCount(); i++) {
CmsSitemapTreeItem item = (CmsSitemapTreeItem)getChild(i);
CmsUUID id = item.getEntryId();
if ((id != null) && (CmsSitemapView.getInstance().getController().getEntryById(id) == null)) {
toDelete.add(item);
}
}
for (CmsSitemapTreeItem deleteItem : toDelete) {
m_children.removeItem(deleteItem);
}
}
} | java | protected void removeInvalidChildren() {
if (getLoadState() == LoadState.LOADED) {
List<CmsSitemapTreeItem> toDelete = new ArrayList<CmsSitemapTreeItem>();
for (int i = 0; i < getChildCount(); i++) {
CmsSitemapTreeItem item = (CmsSitemapTreeItem)getChild(i);
CmsUUID id = item.getEntryId();
if ((id != null) && (CmsSitemapView.getInstance().getController().getEntryById(id) == null)) {
toDelete.add(item);
}
}
for (CmsSitemapTreeItem deleteItem : toDelete) {
m_children.removeItem(deleteItem);
}
}
} | [
"protected",
"void",
"removeInvalidChildren",
"(",
")",
"{",
"if",
"(",
"getLoadState",
"(",
")",
"==",
"LoadState",
".",
"LOADED",
")",
"{",
"List",
"<",
"CmsSitemapTreeItem",
">",
"toDelete",
"=",
"new",
"ArrayList",
"<",
"CmsSitemapTreeItem",
">",
"(",
")... | Helper method to remove invalid children that don't have a corresponding CmsSitemapClientEntry. | [
"Helper",
"method",
"to",
"remove",
"invalid",
"children",
"that",
"don",
"t",
"have",
"a",
"corresponding",
"CmsSitemapClientEntry",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/sitemap/client/CmsSitemapTreeItem.java#L829-L844 | train |
alkacon/opencms-core | src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelDailyView.java | CmsPatternPanelDailyView.onEveryDayChange | @UiHandler("m_everyDay")
void onEveryDayChange(ValueChangeEvent<String> event) {
if (handleChange()) {
m_controller.setInterval(m_everyDay.getFormValueAsString());
}
} | java | @UiHandler("m_everyDay")
void onEveryDayChange(ValueChangeEvent<String> event) {
if (handleChange()) {
m_controller.setInterval(m_everyDay.getFormValueAsString());
}
} | [
"@",
"UiHandler",
"(",
"\"m_everyDay\"",
")",
"void",
"onEveryDayChange",
"(",
"ValueChangeEvent",
"<",
"String",
">",
"event",
")",
"{",
"if",
"(",
"handleChange",
"(",
")",
")",
"{",
"m_controller",
".",
"setInterval",
"(",
"m_everyDay",
".",
"getFormValueAs... | Handle interval change.
@param event the change event. | [
"Handle",
"interval",
"change",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelDailyView.java#L168-L175 | train |
alkacon/opencms-core | src/org/opencms/widgets/CmsLocationPickerWidget.java | CmsLocationPickerWidget.getApiKey | private String getApiKey(CmsObject cms, String sitePath) throws CmsException {
String res = cms.readPropertyObject(
sitePath,
CmsPropertyDefinition.PROPERTY_GOOGLE_API_KEY_WORKPLACE,
true).getValue();
if (CmsStringUtil.isEmptyOrWhitespaceOnly(res)) {
res = cms.readPropertyObject(sitePath, CmsPropertyDefinition.PROPERTY_GOOGLE_API_KEY, true).getValue();
}
return res;
} | java | private String getApiKey(CmsObject cms, String sitePath) throws CmsException {
String res = cms.readPropertyObject(
sitePath,
CmsPropertyDefinition.PROPERTY_GOOGLE_API_KEY_WORKPLACE,
true).getValue();
if (CmsStringUtil.isEmptyOrWhitespaceOnly(res)) {
res = cms.readPropertyObject(sitePath, CmsPropertyDefinition.PROPERTY_GOOGLE_API_KEY, true).getValue();
}
return res;
} | [
"private",
"String",
"getApiKey",
"(",
"CmsObject",
"cms",
",",
"String",
"sitePath",
")",
"throws",
"CmsException",
"{",
"String",
"res",
"=",
"cms",
".",
"readPropertyObject",
"(",
"sitePath",
",",
"CmsPropertyDefinition",
".",
"PROPERTY_GOOGLE_API_KEY_WORKPLACE",
... | Get the correct google api key.
Tries to read a workplace key first.
@param cms CmsObject
@param sitePath site path
@return key value
@throws CmsException exception | [
"Get",
"the",
"correct",
"google",
"api",
"key",
".",
"Tries",
"to",
"read",
"a",
"workplace",
"key",
"first",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/widgets/CmsLocationPickerWidget.java#L309-L321 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/CmsSearchConfiguration.java | CmsSearchConfiguration.propagateFacetNames | private void propagateFacetNames() {
// collect all names and configurations
Collection<String> facetNames = new ArrayList<String>();
Collection<I_CmsSearchConfigurationFacet> facetConfigs = new ArrayList<I_CmsSearchConfigurationFacet>();
facetNames.addAll(m_fieldFacets.keySet());
facetConfigs.addAll(m_fieldFacets.values());
facetNames.addAll(m_rangeFacets.keySet());
facetConfigs.addAll(m_rangeFacets.values());
if (null != m_queryFacet) {
facetNames.add(m_queryFacet.getName());
facetConfigs.add(m_queryFacet);
}
// propagate all names
for (I_CmsSearchConfigurationFacet facetConfig : facetConfigs) {
facetConfig.propagateAllFacetNames(facetNames);
}
} | java | private void propagateFacetNames() {
// collect all names and configurations
Collection<String> facetNames = new ArrayList<String>();
Collection<I_CmsSearchConfigurationFacet> facetConfigs = new ArrayList<I_CmsSearchConfigurationFacet>();
facetNames.addAll(m_fieldFacets.keySet());
facetConfigs.addAll(m_fieldFacets.values());
facetNames.addAll(m_rangeFacets.keySet());
facetConfigs.addAll(m_rangeFacets.values());
if (null != m_queryFacet) {
facetNames.add(m_queryFacet.getName());
facetConfigs.add(m_queryFacet);
}
// propagate all names
for (I_CmsSearchConfigurationFacet facetConfig : facetConfigs) {
facetConfig.propagateAllFacetNames(facetNames);
}
} | [
"private",
"void",
"propagateFacetNames",
"(",
")",
"{",
"// collect all names and configurations",
"Collection",
"<",
"String",
">",
"facetNames",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"Collection",
"<",
"I_CmsSearchConfigurationFacet",
">",
"... | Propagates the names of all facets to each single facet. | [
"Propagates",
"the",
"names",
"of",
"all",
"facets",
"to",
"each",
"single",
"facet",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/CmsSearchConfiguration.java#L156-L174 | train |
alkacon/opencms-core | src/org/opencms/widgets/serialdate/CmsSerialDateBeanWeekly.java | CmsSerialDateBeanWeekly.getDaysToNextMatch | private int getDaysToNextMatch(WeekDay weekDay) {
for (WeekDay wd : m_weekDays) {
if (wd.compareTo(weekDay) > 0) {
return wd.toInt() - weekDay.toInt();
}
}
return (m_weekDays.iterator().next().toInt() + (m_interval * I_CmsSerialDateValue.NUM_OF_WEEKDAYS))
- weekDay.toInt();
} | java | private int getDaysToNextMatch(WeekDay weekDay) {
for (WeekDay wd : m_weekDays) {
if (wd.compareTo(weekDay) > 0) {
return wd.toInt() - weekDay.toInt();
}
}
return (m_weekDays.iterator().next().toInt() + (m_interval * I_CmsSerialDateValue.NUM_OF_WEEKDAYS))
- weekDay.toInt();
} | [
"private",
"int",
"getDaysToNextMatch",
"(",
"WeekDay",
"weekDay",
")",
"{",
"for",
"(",
"WeekDay",
"wd",
":",
"m_weekDays",
")",
"{",
"if",
"(",
"wd",
".",
"compareTo",
"(",
"weekDay",
")",
">",
"0",
")",
"{",
"return",
"wd",
".",
"toInt",
"(",
")",... | Returns the number of days from the given weekday to the next weekday the event should occur.
@param weekDay the current weekday.
@return the number of days to the next weekday an event could occur. | [
"Returns",
"the",
"number",
"of",
"days",
"from",
"the",
"given",
"weekday",
"to",
"the",
"next",
"weekday",
"the",
"event",
"should",
"occur",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/widgets/serialdate/CmsSerialDateBeanWeekly.java#L118-L127 | train |
alkacon/opencms-core | src/org/opencms/util/CmsMacroResolver.java | CmsMacroResolver.newWorkplaceLocaleResolver | public static I_CmsMacroResolver newWorkplaceLocaleResolver(final CmsObject cms) {
// Resolve macros in the property configuration
CmsMacroResolver resolver = new CmsMacroResolver();
resolver.setCmsObject(cms);
CmsUserSettings userSettings = new CmsUserSettings(cms.getRequestContext().getCurrentUser());
CmsMultiMessages multimessages = new CmsMultiMessages(userSettings.getLocale());
multimessages.addMessages(OpenCms.getWorkplaceManager().getMessages(userSettings.getLocale()));
resolver.setMessages(multimessages);
resolver.setKeepEmptyMacros(true);
return resolver;
} | java | public static I_CmsMacroResolver newWorkplaceLocaleResolver(final CmsObject cms) {
// Resolve macros in the property configuration
CmsMacroResolver resolver = new CmsMacroResolver();
resolver.setCmsObject(cms);
CmsUserSettings userSettings = new CmsUserSettings(cms.getRequestContext().getCurrentUser());
CmsMultiMessages multimessages = new CmsMultiMessages(userSettings.getLocale());
multimessages.addMessages(OpenCms.getWorkplaceManager().getMessages(userSettings.getLocale()));
resolver.setMessages(multimessages);
resolver.setKeepEmptyMacros(true);
return resolver;
} | [
"public",
"static",
"I_CmsMacroResolver",
"newWorkplaceLocaleResolver",
"(",
"final",
"CmsObject",
"cms",
")",
"{",
"// Resolve macros in the property configuration",
"CmsMacroResolver",
"resolver",
"=",
"new",
"CmsMacroResolver",
"(",
")",
";",
"resolver",
".",
"setCmsObje... | Returns a new macro resolver that loads message keys from the workplace bundle in the user setting's language.
@param cms the CmsObject.
@return a new macro resolver with messages from the workplace bundle in the current users locale. | [
"Returns",
"a",
"new",
"macro",
"resolver",
"that",
"loads",
"message",
"keys",
"from",
"the",
"workplace",
"bundle",
"in",
"the",
"user",
"setting",
"s",
"language",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/util/CmsMacroResolver.java#L495-L507 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.parseMandatoryStringValues | protected static List<String> parseMandatoryStringValues(JSONObject json, String key) throws JSONException {
List<String> list = null;
JSONArray array = json.getJSONArray(key);
list = new ArrayList<String>(array.length());
for (int i = 0; i < array.length(); i++) {
try {
String entry = array.getString(i);
list.add(entry);
} catch (JSONException e) {
LOG.info(Messages.get().getBundle().key(Messages.LOG_OPTIONAL_STRING_ENTRY_UNPARSABLE_1, key), e);
}
}
return list;
} | java | protected static List<String> parseMandatoryStringValues(JSONObject json, String key) throws JSONException {
List<String> list = null;
JSONArray array = json.getJSONArray(key);
list = new ArrayList<String>(array.length());
for (int i = 0; i < array.length(); i++) {
try {
String entry = array.getString(i);
list.add(entry);
} catch (JSONException e) {
LOG.info(Messages.get().getBundle().key(Messages.LOG_OPTIONAL_STRING_ENTRY_UNPARSABLE_1, key), e);
}
}
return list;
} | [
"protected",
"static",
"List",
"<",
"String",
">",
"parseMandatoryStringValues",
"(",
"JSONObject",
"json",
",",
"String",
"key",
")",
"throws",
"JSONException",
"{",
"List",
"<",
"String",
">",
"list",
"=",
"null",
";",
"JSONArray",
"array",
"=",
"json",
".... | Helper for reading a mandatory String value list - throwing an Exception if parsing fails.
@param json The JSON object where the list should be read from.
@param key The key of the value to read.
@return The value from the JSON.
@throws JSONException thrown when parsing fails. | [
"Helper",
"for",
"reading",
"a",
"mandatory",
"String",
"value",
"list",
"-",
"throwing",
"an",
"Exception",
"if",
"parsing",
"fails",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L248-L262 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.getEscapeQueryChars | protected Boolean getEscapeQueryChars() {
Boolean isEscape = parseOptionalBooleanValue(m_configObject, JSON_KEY_ESCAPE_QUERY_CHARACTERS);
return (null == isEscape) && (m_baseConfig != null)
? Boolean.valueOf(m_baseConfig.getGeneralConfig().getEscapeQueryChars())
: isEscape;
} | java | protected Boolean getEscapeQueryChars() {
Boolean isEscape = parseOptionalBooleanValue(m_configObject, JSON_KEY_ESCAPE_QUERY_CHARACTERS);
return (null == isEscape) && (m_baseConfig != null)
? Boolean.valueOf(m_baseConfig.getGeneralConfig().getEscapeQueryChars())
: isEscape;
} | [
"protected",
"Boolean",
"getEscapeQueryChars",
"(",
")",
"{",
"Boolean",
"isEscape",
"=",
"parseOptionalBooleanValue",
"(",
"m_configObject",
",",
"JSON_KEY_ESCAPE_QUERY_CHARACTERS",
")",
";",
"return",
"(",
"null",
"==",
"isEscape",
")",
"&&",
"(",
"m_baseConfig",
... | Returns the flag, indicating if the characters in the query string that are commands to Solr should be escaped.
@return the flag, indicating if the characters in the query string that are commands to Solr should be escaped. | [
"Returns",
"the",
"flag",
"indicating",
"if",
"the",
"characters",
"in",
"the",
"query",
"string",
"that",
"are",
"commands",
"to",
"Solr",
"should",
"be",
"escaped",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L588-L594 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.getExtraSolrParams | protected String getExtraSolrParams() {
try {
return m_configObject.getString(JSON_KEY_EXTRASOLRPARAMS);
} catch (JSONException e) {
if (null == m_baseConfig) {
if (LOG.isInfoEnabled()) {
LOG.info(Messages.get().getBundle().key(Messages.LOG_NO_EXTRA_PARAMETERS_0), e);
}
return "";
} else {
return m_baseConfig.getGeneralConfig().getExtraSolrParams();
}
}
} | java | protected String getExtraSolrParams() {
try {
return m_configObject.getString(JSON_KEY_EXTRASOLRPARAMS);
} catch (JSONException e) {
if (null == m_baseConfig) {
if (LOG.isInfoEnabled()) {
LOG.info(Messages.get().getBundle().key(Messages.LOG_NO_EXTRA_PARAMETERS_0), e);
}
return "";
} else {
return m_baseConfig.getGeneralConfig().getExtraSolrParams();
}
}
} | [
"protected",
"String",
"getExtraSolrParams",
"(",
")",
"{",
"try",
"{",
"return",
"m_configObject",
".",
"getString",
"(",
"JSON_KEY_EXTRASOLRPARAMS",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"if",
"(",
"null",
"==",
"m_baseConfig",
")",
... | Returns the configured extra parameters that should be given to Solr, or the empty string if no parameters are configured.
@return The configured extra parameters that should be given to Solr, or the empty string if no parameters are configured. | [
"Returns",
"the",
"configured",
"extra",
"parameters",
"that",
"should",
"be",
"given",
"to",
"Solr",
"or",
"the",
"empty",
"string",
"if",
"no",
"parameters",
"are",
"configured",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L599-L613 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.getIgnoreExpirationDate | protected Boolean getIgnoreExpirationDate() {
Boolean isIgnoreExpirationDate = parseOptionalBooleanValue(m_configObject, JSON_KEY_IGNORE_EXPIRATION_DATE);
return (null == isIgnoreExpirationDate) && (m_baseConfig != null)
? Boolean.valueOf(m_baseConfig.getGeneralConfig().getIgnoreExpirationDate())
: isIgnoreExpirationDate;
} | java | protected Boolean getIgnoreExpirationDate() {
Boolean isIgnoreExpirationDate = parseOptionalBooleanValue(m_configObject, JSON_KEY_IGNORE_EXPIRATION_DATE);
return (null == isIgnoreExpirationDate) && (m_baseConfig != null)
? Boolean.valueOf(m_baseConfig.getGeneralConfig().getIgnoreExpirationDate())
: isIgnoreExpirationDate;
} | [
"protected",
"Boolean",
"getIgnoreExpirationDate",
"(",
")",
"{",
"Boolean",
"isIgnoreExpirationDate",
"=",
"parseOptionalBooleanValue",
"(",
"m_configObject",
",",
"JSON_KEY_IGNORE_EXPIRATION_DATE",
")",
";",
"return",
"(",
"null",
"==",
"isIgnoreExpirationDate",
")",
"&... | Returns a flag indicating if also expired resources should be found.
@return A flag indicating if also expired resources should be found. | [
"Returns",
"a",
"flag",
"indicating",
"if",
"also",
"expired",
"resources",
"should",
"be",
"found",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L631-L637 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.getIgnoreQuery | protected Boolean getIgnoreQuery() {
Boolean isIgnoreQuery = parseOptionalBooleanValue(m_configObject, JSON_KEY_IGNORE_QUERY);
return (null == isIgnoreQuery) && (m_baseConfig != null)
? Boolean.valueOf(m_baseConfig.getGeneralConfig().getIgnoreQueryParam())
: isIgnoreQuery;
} | java | protected Boolean getIgnoreQuery() {
Boolean isIgnoreQuery = parseOptionalBooleanValue(m_configObject, JSON_KEY_IGNORE_QUERY);
return (null == isIgnoreQuery) && (m_baseConfig != null)
? Boolean.valueOf(m_baseConfig.getGeneralConfig().getIgnoreQueryParam())
: isIgnoreQuery;
} | [
"protected",
"Boolean",
"getIgnoreQuery",
"(",
")",
"{",
"Boolean",
"isIgnoreQuery",
"=",
"parseOptionalBooleanValue",
"(",
"m_configObject",
",",
"JSON_KEY_IGNORE_QUERY",
")",
";",
"return",
"(",
"null",
"==",
"isIgnoreQuery",
")",
"&&",
"(",
"m_baseConfig",
"!=",
... | Returns a flag indicating if the query given by the parameters should be ignored.
@return A flag indicating if the query given by the parameters should be ignored. | [
"Returns",
"a",
"flag",
"indicating",
"if",
"the",
"query",
"given",
"by",
"the",
"parameters",
"should",
"be",
"ignored",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L642-L648 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.getIgnoreReleaseDate | protected Boolean getIgnoreReleaseDate() {
Boolean isIgnoreReleaseDate = parseOptionalBooleanValue(m_configObject, JSON_KEY_IGNORE_RELEASE_DATE);
return (null == isIgnoreReleaseDate) && (m_baseConfig != null)
? Boolean.valueOf(m_baseConfig.getGeneralConfig().getIgnoreReleaseDate())
: isIgnoreReleaseDate;
} | java | protected Boolean getIgnoreReleaseDate() {
Boolean isIgnoreReleaseDate = parseOptionalBooleanValue(m_configObject, JSON_KEY_IGNORE_RELEASE_DATE);
return (null == isIgnoreReleaseDate) && (m_baseConfig != null)
? Boolean.valueOf(m_baseConfig.getGeneralConfig().getIgnoreReleaseDate())
: isIgnoreReleaseDate;
} | [
"protected",
"Boolean",
"getIgnoreReleaseDate",
"(",
")",
"{",
"Boolean",
"isIgnoreReleaseDate",
"=",
"parseOptionalBooleanValue",
"(",
"m_configObject",
",",
"JSON_KEY_IGNORE_RELEASE_DATE",
")",
";",
"return",
"(",
"null",
"==",
"isIgnoreReleaseDate",
")",
"&&",
"(",
... | Returns a flag indicating if also unreleased resources should be found.
@return A flag indicating if also unreleased resources should be found. | [
"Returns",
"a",
"flag",
"indicating",
"if",
"also",
"unreleased",
"resources",
"should",
"be",
"found",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L653-L659 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.getPageSizes | protected List<Integer> getPageSizes() {
try {
return Collections.singletonList(Integer.valueOf(m_configObject.getInt(JSON_KEY_PAGESIZE)));
} catch (JSONException e) {
List<Integer> result = null;
String pageSizesString = null;
try {
pageSizesString = m_configObject.getString(JSON_KEY_PAGESIZE);
String[] pageSizesArray = pageSizesString.split("-");
if (pageSizesArray.length > 0) {
result = new ArrayList<>(pageSizesArray.length);
for (int i = 0; i < pageSizesArray.length; i++) {
result.add(Integer.valueOf(pageSizesArray[i]));
}
}
return result;
} catch (NumberFormatException | JSONException e1) {
LOG.warn(Messages.get().getBundle().key(Messages.LOG_PARSING_PAGE_SIZES_FAILED_1, pageSizesString), e);
}
if (null == m_baseConfig) {
if (LOG.isInfoEnabled()) {
LOG.info(Messages.get().getBundle().key(Messages.LOG_NO_PAGESIZE_SPECIFIED_0), e);
}
return null;
} else {
return m_baseConfig.getPaginationConfig().getPageSizes();
}
}
} | java | protected List<Integer> getPageSizes() {
try {
return Collections.singletonList(Integer.valueOf(m_configObject.getInt(JSON_KEY_PAGESIZE)));
} catch (JSONException e) {
List<Integer> result = null;
String pageSizesString = null;
try {
pageSizesString = m_configObject.getString(JSON_KEY_PAGESIZE);
String[] pageSizesArray = pageSizesString.split("-");
if (pageSizesArray.length > 0) {
result = new ArrayList<>(pageSizesArray.length);
for (int i = 0; i < pageSizesArray.length; i++) {
result.add(Integer.valueOf(pageSizesArray[i]));
}
}
return result;
} catch (NumberFormatException | JSONException e1) {
LOG.warn(Messages.get().getBundle().key(Messages.LOG_PARSING_PAGE_SIZES_FAILED_1, pageSizesString), e);
}
if (null == m_baseConfig) {
if (LOG.isInfoEnabled()) {
LOG.info(Messages.get().getBundle().key(Messages.LOG_NO_PAGESIZE_SPECIFIED_0), e);
}
return null;
} else {
return m_baseConfig.getPaginationConfig().getPageSizes();
}
}
} | [
"protected",
"List",
"<",
"Integer",
">",
"getPageSizes",
"(",
")",
"{",
"try",
"{",
"return",
"Collections",
".",
"singletonList",
"(",
"Integer",
".",
"valueOf",
"(",
"m_configObject",
".",
"getInt",
"(",
"JSON_KEY_PAGESIZE",
")",
")",
")",
";",
"}",
"ca... | Returns the configured page sizes, or the default page size if no core is configured.
@return The configured page sizes, or the default page size if no core is configured. | [
"Returns",
"the",
"configured",
"page",
"sizes",
"or",
"the",
"default",
"page",
"size",
"if",
"no",
"core",
"is",
"configured",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L714-L743 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.getQueryModifier | protected String getQueryModifier() {
String queryModifier = parseOptionalStringValue(m_configObject, JSON_KEY_QUERY_MODIFIER);
return (null == queryModifier) && (null != m_baseConfig)
? m_baseConfig.getGeneralConfig().getQueryModifier()
: queryModifier;
} | java | protected String getQueryModifier() {
String queryModifier = parseOptionalStringValue(m_configObject, JSON_KEY_QUERY_MODIFIER);
return (null == queryModifier) && (null != m_baseConfig)
? m_baseConfig.getGeneralConfig().getQueryModifier()
: queryModifier;
} | [
"protected",
"String",
"getQueryModifier",
"(",
")",
"{",
"String",
"queryModifier",
"=",
"parseOptionalStringValue",
"(",
"m_configObject",
",",
"JSON_KEY_QUERY_MODIFIER",
")",
";",
"return",
"(",
"null",
"==",
"queryModifier",
")",
"&&",
"(",
"null",
"!=",
"m_ba... | Returns the optional query modifier.
@return the optional query modifier. | [
"Returns",
"the",
"optional",
"query",
"modifier",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L748-L754 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.getQueryParam | protected String getQueryParam() {
String param = parseOptionalStringValue(m_configObject, JSON_KEY_QUERYPARAM);
if (param == null) {
return null != m_baseConfig ? m_baseConfig.getGeneralConfig().getQueryParam() : DEFAULT_QUERY_PARAM;
} else {
return param;
}
} | java | protected String getQueryParam() {
String param = parseOptionalStringValue(m_configObject, JSON_KEY_QUERYPARAM);
if (param == null) {
return null != m_baseConfig ? m_baseConfig.getGeneralConfig().getQueryParam() : DEFAULT_QUERY_PARAM;
} else {
return param;
}
} | [
"protected",
"String",
"getQueryParam",
"(",
")",
"{",
"String",
"param",
"=",
"parseOptionalStringValue",
"(",
"m_configObject",
",",
"JSON_KEY_QUERYPARAM",
")",
";",
"if",
"(",
"param",
"==",
"null",
")",
"{",
"return",
"null",
"!=",
"m_baseConfig",
"?",
"m_... | Returns the configured request parameter for the query string, or the default parameter if no core is configured.
@return The configured request parameter for the query string, or the default parameter if no core is configured. | [
"Returns",
"the",
"configured",
"request",
"parameter",
"for",
"the",
"query",
"string",
"or",
"the",
"default",
"parameter",
"if",
"no",
"core",
"is",
"configured",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L759-L767 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.getSearchForEmptyQuery | protected Boolean getSearchForEmptyQuery() {
Boolean isSearchForEmptyQuery = parseOptionalBooleanValue(m_configObject, JSON_KEY_SEARCH_FOR_EMPTY_QUERY);
return (isSearchForEmptyQuery == null) && (null != m_baseConfig)
? Boolean.valueOf(m_baseConfig.getGeneralConfig().getSearchForEmptyQueryParam())
: isSearchForEmptyQuery;
} | java | protected Boolean getSearchForEmptyQuery() {
Boolean isSearchForEmptyQuery = parseOptionalBooleanValue(m_configObject, JSON_KEY_SEARCH_FOR_EMPTY_QUERY);
return (isSearchForEmptyQuery == null) && (null != m_baseConfig)
? Boolean.valueOf(m_baseConfig.getGeneralConfig().getSearchForEmptyQueryParam())
: isSearchForEmptyQuery;
} | [
"protected",
"Boolean",
"getSearchForEmptyQuery",
"(",
")",
"{",
"Boolean",
"isSearchForEmptyQuery",
"=",
"parseOptionalBooleanValue",
"(",
"m_configObject",
",",
"JSON_KEY_SEARCH_FOR_EMPTY_QUERY",
")",
";",
"return",
"(",
"isSearchForEmptyQuery",
"==",
"null",
")",
"&&",... | Returns a flag, indicating if search should be performed using a wildcard if the empty query is given.
@return A flag, indicating if search should be performed using a wildcard if the empty query is given. | [
"Returns",
"a",
"flag",
"indicating",
"if",
"search",
"should",
"be",
"performed",
"using",
"a",
"wildcard",
"if",
"the",
"empty",
"query",
"is",
"given",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L772-L778 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.getSortOptions | protected List<I_CmsSearchConfigurationSortOption> getSortOptions() {
List<I_CmsSearchConfigurationSortOption> options = new LinkedList<I_CmsSearchConfigurationSortOption>();
try {
JSONArray sortOptions = m_configObject.getJSONArray(JSON_KEY_SORTOPTIONS);
for (int i = 0; i < sortOptions.length(); i++) {
I_CmsSearchConfigurationSortOption option = parseSortOption(sortOptions.getJSONObject(i));
if (option != null) {
options.add(option);
}
}
} catch (JSONException e) {
if (null == m_baseConfig) {
if (LOG.isInfoEnabled()) {
LOG.info(Messages.get().getBundle().key(Messages.LOG_NO_SORT_CONFIG_0), e);
}
} else {
options = m_baseConfig.getSortConfig().getSortOptions();
}
}
return options;
} | java | protected List<I_CmsSearchConfigurationSortOption> getSortOptions() {
List<I_CmsSearchConfigurationSortOption> options = new LinkedList<I_CmsSearchConfigurationSortOption>();
try {
JSONArray sortOptions = m_configObject.getJSONArray(JSON_KEY_SORTOPTIONS);
for (int i = 0; i < sortOptions.length(); i++) {
I_CmsSearchConfigurationSortOption option = parseSortOption(sortOptions.getJSONObject(i));
if (option != null) {
options.add(option);
}
}
} catch (JSONException e) {
if (null == m_baseConfig) {
if (LOG.isInfoEnabled()) {
LOG.info(Messages.get().getBundle().key(Messages.LOG_NO_SORT_CONFIG_0), e);
}
} else {
options = m_baseConfig.getSortConfig().getSortOptions();
}
}
return options;
} | [
"protected",
"List",
"<",
"I_CmsSearchConfigurationSortOption",
">",
"getSortOptions",
"(",
")",
"{",
"List",
"<",
"I_CmsSearchConfigurationSortOption",
">",
"options",
"=",
"new",
"LinkedList",
"<",
"I_CmsSearchConfigurationSortOption",
">",
"(",
")",
";",
"try",
"{"... | Returns the list of the configured sort options, or the empty list if no sort options are configured.
@return The list of the configured sort options, or the empty list if no sort options are configured. | [
"Returns",
"the",
"list",
"of",
"the",
"configured",
"sort",
"options",
"or",
"the",
"empty",
"list",
"if",
"no",
"sort",
"options",
"are",
"configured",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L783-L804 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.init | protected void init(String configString, I_CmsSearchConfiguration baseConfig) throws JSONException {
m_configObject = new JSONObject(configString);
m_baseConfig = baseConfig;
} | java | protected void init(String configString, I_CmsSearchConfiguration baseConfig) throws JSONException {
m_configObject = new JSONObject(configString);
m_baseConfig = baseConfig;
} | [
"protected",
"void",
"init",
"(",
"String",
"configString",
",",
"I_CmsSearchConfiguration",
"baseConfig",
")",
"throws",
"JSONException",
"{",
"m_configObject",
"=",
"new",
"JSONObject",
"(",
"configString",
")",
";",
"m_baseConfig",
"=",
"baseConfig",
";",
"}"
] | Initialization that parses the String to a JSON object.
@param configString The JSON as string.
@param baseConfig The optional basic search configuration to overwrite (partly) by the JSON configuration.
@throws JSONException thrown if parsing fails. | [
"Initialization",
"that",
"parses",
"the",
"String",
"to",
"a",
"JSON",
"object",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L819-L823 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.parseFacetQueryItem | protected I_CmsFacetQueryItem parseFacetQueryItem(JSONObject item) {
String query;
try {
query = item.getString(JSON_KEY_QUERY_FACET_QUERY_QUERY);
} catch (JSONException e) {
// TODO: Log
return null;
}
String label = parseOptionalStringValue(item, JSON_KEY_QUERY_FACET_QUERY_LABEL);
return new CmsFacetQueryItem(query, label);
} | java | protected I_CmsFacetQueryItem parseFacetQueryItem(JSONObject item) {
String query;
try {
query = item.getString(JSON_KEY_QUERY_FACET_QUERY_QUERY);
} catch (JSONException e) {
// TODO: Log
return null;
}
String label = parseOptionalStringValue(item, JSON_KEY_QUERY_FACET_QUERY_LABEL);
return new CmsFacetQueryItem(query, label);
} | [
"protected",
"I_CmsFacetQueryItem",
"parseFacetQueryItem",
"(",
"JSONObject",
"item",
")",
"{",
"String",
"query",
";",
"try",
"{",
"query",
"=",
"item",
".",
"getString",
"(",
"JSON_KEY_QUERY_FACET_QUERY_QUERY",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
... | Parses a single query item for the query facet.
@param item JSON object of the query item.
@return the parsed query item, or <code>null</code> if parsing failed. | [
"Parses",
"a",
"single",
"query",
"item",
"for",
"the",
"query",
"facet",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L829-L840 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.parseFacetQueryItems | protected List<I_CmsFacetQueryItem> parseFacetQueryItems(JSONObject queryFacetObject) throws JSONException {
JSONArray items = queryFacetObject.getJSONArray(JSON_KEY_QUERY_FACET_QUERY);
List<I_CmsFacetQueryItem> result = new ArrayList<I_CmsFacetQueryItem>(items.length());
for (int i = 0; i < items.length(); i++) {
I_CmsFacetQueryItem item = parseFacetQueryItem(items.getJSONObject(i));
if (item != null) {
result.add(item);
}
}
return result;
} | java | protected List<I_CmsFacetQueryItem> parseFacetQueryItems(JSONObject queryFacetObject) throws JSONException {
JSONArray items = queryFacetObject.getJSONArray(JSON_KEY_QUERY_FACET_QUERY);
List<I_CmsFacetQueryItem> result = new ArrayList<I_CmsFacetQueryItem>(items.length());
for (int i = 0; i < items.length(); i++) {
I_CmsFacetQueryItem item = parseFacetQueryItem(items.getJSONObject(i));
if (item != null) {
result.add(item);
}
}
return result;
} | [
"protected",
"List",
"<",
"I_CmsFacetQueryItem",
">",
"parseFacetQueryItems",
"(",
"JSONObject",
"queryFacetObject",
")",
"throws",
"JSONException",
"{",
"JSONArray",
"items",
"=",
"queryFacetObject",
".",
"getJSONArray",
"(",
"JSON_KEY_QUERY_FACET_QUERY",
")",
";",
"Li... | Parses the list of query items for the query facet.
@param queryFacetObject JSON object representing the node with the query facet.
@return list of query options
@throws JSONException if the list cannot be parsed. | [
"Parses",
"the",
"list",
"of",
"query",
"items",
"for",
"the",
"query",
"facet",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L847-L858 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.parseFieldFacet | protected I_CmsSearchConfigurationFacetField parseFieldFacet(JSONObject fieldFacetObject) {
try {
String field = fieldFacetObject.getString(JSON_KEY_FACET_FIELD);
String name = parseOptionalStringValue(fieldFacetObject, JSON_KEY_FACET_NAME);
String label = parseOptionalStringValue(fieldFacetObject, JSON_KEY_FACET_LABEL);
Integer minCount = parseOptionalIntValue(fieldFacetObject, JSON_KEY_FACET_MINCOUNT);
Integer limit = parseOptionalIntValue(fieldFacetObject, JSON_KEY_FACET_LIMIT);
String prefix = parseOptionalStringValue(fieldFacetObject, JSON_KEY_FACET_PREFIX);
String sorder = parseOptionalStringValue(fieldFacetObject, JSON_KEY_FACET_ORDER);
I_CmsSearchConfigurationFacet.SortOrder order;
try {
order = I_CmsSearchConfigurationFacet.SortOrder.valueOf(sorder);
} catch (Exception e) {
order = null;
}
String filterQueryModifier = parseOptionalStringValue(fieldFacetObject, JSON_KEY_FACET_FILTERQUERYMODIFIER);
Boolean isAndFacet = parseOptionalBooleanValue(fieldFacetObject, JSON_KEY_FACET_ISANDFACET);
List<String> preselection = parseOptionalStringValues(fieldFacetObject, JSON_KEY_FACET_PRESELECTION);
Boolean ignoreFilterAllFacetFilters = parseOptionalBooleanValue(
fieldFacetObject,
JSON_KEY_FACET_IGNOREALLFACETFILTERS);
return new CmsSearchConfigurationFacetField(
field,
name,
minCount,
limit,
prefix,
label,
order,
filterQueryModifier,
isAndFacet,
preselection,
ignoreFilterAllFacetFilters);
} catch (JSONException e) {
LOG.error(
Messages.get().getBundle().key(Messages.ERR_FIELD_FACET_MANDATORY_KEY_MISSING_1, JSON_KEY_FACET_FIELD),
e);
return null;
}
} | java | protected I_CmsSearchConfigurationFacetField parseFieldFacet(JSONObject fieldFacetObject) {
try {
String field = fieldFacetObject.getString(JSON_KEY_FACET_FIELD);
String name = parseOptionalStringValue(fieldFacetObject, JSON_KEY_FACET_NAME);
String label = parseOptionalStringValue(fieldFacetObject, JSON_KEY_FACET_LABEL);
Integer minCount = parseOptionalIntValue(fieldFacetObject, JSON_KEY_FACET_MINCOUNT);
Integer limit = parseOptionalIntValue(fieldFacetObject, JSON_KEY_FACET_LIMIT);
String prefix = parseOptionalStringValue(fieldFacetObject, JSON_KEY_FACET_PREFIX);
String sorder = parseOptionalStringValue(fieldFacetObject, JSON_KEY_FACET_ORDER);
I_CmsSearchConfigurationFacet.SortOrder order;
try {
order = I_CmsSearchConfigurationFacet.SortOrder.valueOf(sorder);
} catch (Exception e) {
order = null;
}
String filterQueryModifier = parseOptionalStringValue(fieldFacetObject, JSON_KEY_FACET_FILTERQUERYMODIFIER);
Boolean isAndFacet = parseOptionalBooleanValue(fieldFacetObject, JSON_KEY_FACET_ISANDFACET);
List<String> preselection = parseOptionalStringValues(fieldFacetObject, JSON_KEY_FACET_PRESELECTION);
Boolean ignoreFilterAllFacetFilters = parseOptionalBooleanValue(
fieldFacetObject,
JSON_KEY_FACET_IGNOREALLFACETFILTERS);
return new CmsSearchConfigurationFacetField(
field,
name,
minCount,
limit,
prefix,
label,
order,
filterQueryModifier,
isAndFacet,
preselection,
ignoreFilterAllFacetFilters);
} catch (JSONException e) {
LOG.error(
Messages.get().getBundle().key(Messages.ERR_FIELD_FACET_MANDATORY_KEY_MISSING_1, JSON_KEY_FACET_FIELD),
e);
return null;
}
} | [
"protected",
"I_CmsSearchConfigurationFacetField",
"parseFieldFacet",
"(",
"JSONObject",
"fieldFacetObject",
")",
"{",
"try",
"{",
"String",
"field",
"=",
"fieldFacetObject",
".",
"getString",
"(",
"JSON_KEY_FACET_FIELD",
")",
";",
"String",
"name",
"=",
"parseOptionalS... | Parses the field facet configurations.
@param fieldFacetObject The JSON sub-node with the field facet configurations.
@return The field facet configurations. | [
"Parses",
"the",
"field",
"facet",
"configurations",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L864-L904 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.parseRangeFacet | protected I_CmsSearchConfigurationFacetRange parseRangeFacet(JSONObject rangeFacetObject) {
try {
String range = rangeFacetObject.getString(JSON_KEY_RANGE_FACET_RANGE);
String name = parseOptionalStringValue(rangeFacetObject, JSON_KEY_FACET_NAME);
String label = parseOptionalStringValue(rangeFacetObject, JSON_KEY_FACET_LABEL);
Integer minCount = parseOptionalIntValue(rangeFacetObject, JSON_KEY_FACET_MINCOUNT);
String start = rangeFacetObject.getString(JSON_KEY_RANGE_FACET_START);
String end = rangeFacetObject.getString(JSON_KEY_RANGE_FACET_END);
String gap = rangeFacetObject.getString(JSON_KEY_RANGE_FACET_GAP);
List<String> sother = parseOptionalStringValues(rangeFacetObject, JSON_KEY_RANGE_FACET_OTHER);
Boolean hardEnd = parseOptionalBooleanValue(rangeFacetObject, JSON_KEY_RANGE_FACET_HARDEND);
List<I_CmsSearchConfigurationFacetRange.Other> other = null;
if (sother != null) {
other = new ArrayList<I_CmsSearchConfigurationFacetRange.Other>(sother.size());
for (String so : sother) {
try {
I_CmsSearchConfigurationFacetRange.Other o = I_CmsSearchConfigurationFacetRange.Other.valueOf(
so);
other.add(o);
} catch (Exception e) {
LOG.error(Messages.get().getBundle().key(Messages.ERR_INVALID_OTHER_OPTION_1, so), e);
}
}
}
Boolean isAndFacet = parseOptionalBooleanValue(rangeFacetObject, JSON_KEY_FACET_ISANDFACET);
List<String> preselection = parseOptionalStringValues(rangeFacetObject, JSON_KEY_FACET_PRESELECTION);
Boolean ignoreAllFacetFilters = parseOptionalBooleanValue(
rangeFacetObject,
JSON_KEY_FACET_IGNOREALLFACETFILTERS);
return new CmsSearchConfigurationFacetRange(
range,
start,
end,
gap,
other,
hardEnd,
name,
minCount,
label,
isAndFacet,
preselection,
ignoreAllFacetFilters);
} catch (JSONException e) {
LOG.error(
Messages.get().getBundle().key(
Messages.ERR_RANGE_FACET_MANDATORY_KEY_MISSING_1,
JSON_KEY_RANGE_FACET_RANGE
+ ", "
+ JSON_KEY_RANGE_FACET_START
+ ", "
+ JSON_KEY_RANGE_FACET_END
+ ", "
+ JSON_KEY_RANGE_FACET_GAP),
e);
return null;
}
} | java | protected I_CmsSearchConfigurationFacetRange parseRangeFacet(JSONObject rangeFacetObject) {
try {
String range = rangeFacetObject.getString(JSON_KEY_RANGE_FACET_RANGE);
String name = parseOptionalStringValue(rangeFacetObject, JSON_KEY_FACET_NAME);
String label = parseOptionalStringValue(rangeFacetObject, JSON_KEY_FACET_LABEL);
Integer minCount = parseOptionalIntValue(rangeFacetObject, JSON_KEY_FACET_MINCOUNT);
String start = rangeFacetObject.getString(JSON_KEY_RANGE_FACET_START);
String end = rangeFacetObject.getString(JSON_KEY_RANGE_FACET_END);
String gap = rangeFacetObject.getString(JSON_KEY_RANGE_FACET_GAP);
List<String> sother = parseOptionalStringValues(rangeFacetObject, JSON_KEY_RANGE_FACET_OTHER);
Boolean hardEnd = parseOptionalBooleanValue(rangeFacetObject, JSON_KEY_RANGE_FACET_HARDEND);
List<I_CmsSearchConfigurationFacetRange.Other> other = null;
if (sother != null) {
other = new ArrayList<I_CmsSearchConfigurationFacetRange.Other>(sother.size());
for (String so : sother) {
try {
I_CmsSearchConfigurationFacetRange.Other o = I_CmsSearchConfigurationFacetRange.Other.valueOf(
so);
other.add(o);
} catch (Exception e) {
LOG.error(Messages.get().getBundle().key(Messages.ERR_INVALID_OTHER_OPTION_1, so), e);
}
}
}
Boolean isAndFacet = parseOptionalBooleanValue(rangeFacetObject, JSON_KEY_FACET_ISANDFACET);
List<String> preselection = parseOptionalStringValues(rangeFacetObject, JSON_KEY_FACET_PRESELECTION);
Boolean ignoreAllFacetFilters = parseOptionalBooleanValue(
rangeFacetObject,
JSON_KEY_FACET_IGNOREALLFACETFILTERS);
return new CmsSearchConfigurationFacetRange(
range,
start,
end,
gap,
other,
hardEnd,
name,
minCount,
label,
isAndFacet,
preselection,
ignoreAllFacetFilters);
} catch (JSONException e) {
LOG.error(
Messages.get().getBundle().key(
Messages.ERR_RANGE_FACET_MANDATORY_KEY_MISSING_1,
JSON_KEY_RANGE_FACET_RANGE
+ ", "
+ JSON_KEY_RANGE_FACET_START
+ ", "
+ JSON_KEY_RANGE_FACET_END
+ ", "
+ JSON_KEY_RANGE_FACET_GAP),
e);
return null;
}
} | [
"protected",
"I_CmsSearchConfigurationFacetRange",
"parseRangeFacet",
"(",
"JSONObject",
"rangeFacetObject",
")",
"{",
"try",
"{",
"String",
"range",
"=",
"rangeFacetObject",
".",
"getString",
"(",
"JSON_KEY_RANGE_FACET_RANGE",
")",
";",
"String",
"name",
"=",
"parseOpt... | Parses the query facet configurations.
@param rangeFacetObject The JSON sub-node with the query facet configurations.
@return The query facet configurations. | [
"Parses",
"the",
"query",
"facet",
"configurations",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L910-L968 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.parseSortOption | protected I_CmsSearchConfigurationSortOption parseSortOption(JSONObject json) {
try {
String solrValue = json.getString(JSON_KEY_SORTOPTION_SOLRVALUE);
String paramValue = parseOptionalStringValue(json, JSON_KEY_SORTOPTION_PARAMVALUE);
paramValue = (paramValue == null) ? solrValue : paramValue;
String label = parseOptionalStringValue(json, JSON_KEY_SORTOPTION_LABEL);
label = (label == null) ? paramValue : label;
return new CmsSearchConfigurationSortOption(label, paramValue, solrValue);
} catch (JSONException e) {
LOG.error(
Messages.get().getBundle().key(Messages.ERR_SORT_OPTION_NOT_PARSABLE_1, JSON_KEY_SORTOPTION_SOLRVALUE),
e);
return null;
}
} | java | protected I_CmsSearchConfigurationSortOption parseSortOption(JSONObject json) {
try {
String solrValue = json.getString(JSON_KEY_SORTOPTION_SOLRVALUE);
String paramValue = parseOptionalStringValue(json, JSON_KEY_SORTOPTION_PARAMVALUE);
paramValue = (paramValue == null) ? solrValue : paramValue;
String label = parseOptionalStringValue(json, JSON_KEY_SORTOPTION_LABEL);
label = (label == null) ? paramValue : label;
return new CmsSearchConfigurationSortOption(label, paramValue, solrValue);
} catch (JSONException e) {
LOG.error(
Messages.get().getBundle().key(Messages.ERR_SORT_OPTION_NOT_PARSABLE_1, JSON_KEY_SORTOPTION_SOLRVALUE),
e);
return null;
}
} | [
"protected",
"I_CmsSearchConfigurationSortOption",
"parseSortOption",
"(",
"JSONObject",
"json",
")",
"{",
"try",
"{",
"String",
"solrValue",
"=",
"json",
".",
"getString",
"(",
"JSON_KEY_SORTOPTION_SOLRVALUE",
")",
";",
"String",
"paramValue",
"=",
"parseOptionalString... | Returns a single sort option configuration as configured via the methods parameter, or null if the parameter does not specify a sort option.
@param json The JSON sort option configuration.
@return The sort option configuration, or null if the JSON could not be read. | [
"Returns",
"a",
"single",
"sort",
"option",
"configuration",
"as",
"configured",
"via",
"the",
"methods",
"parameter",
"or",
"null",
"if",
"the",
"parameter",
"does",
"not",
"specify",
"a",
"sort",
"option",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L974-L989 | train |
alkacon/opencms-core | src/org/opencms/search/extractors/CmsExtractionResult.java | CmsExtractionResult.mergeItem | private Map<String, String> mergeItem(
String item,
Map<String, String> localeValues,
Map<String, String> resultLocaleValues) {
if (resultLocaleValues.get(item) != null) {
if (localeValues.get(item) != null) {
localeValues.put(item, localeValues.get(item) + " " + resultLocaleValues.get(item));
} else {
localeValues.put(item, resultLocaleValues.get(item));
}
}
return localeValues;
} | java | private Map<String, String> mergeItem(
String item,
Map<String, String> localeValues,
Map<String, String> resultLocaleValues) {
if (resultLocaleValues.get(item) != null) {
if (localeValues.get(item) != null) {
localeValues.put(item, localeValues.get(item) + " " + resultLocaleValues.get(item));
} else {
localeValues.put(item, resultLocaleValues.get(item));
}
}
return localeValues;
} | [
"private",
"Map",
"<",
"String",
",",
"String",
">",
"mergeItem",
"(",
"String",
"item",
",",
"Map",
"<",
"String",
",",
"String",
">",
"localeValues",
",",
"Map",
"<",
"String",
",",
"String",
">",
"resultLocaleValues",
")",
"{",
"if",
"(",
"resultLocal... | Merges the item from the resultLocaleValues into the corresponding item of the localeValues.
@param item the item to merge
@param localeValues the values where the item gets merged into
@param resultLocaleValues the values where the item to merge is read from
@return the modified localeValues with the merged item | [
"Merges",
"the",
"item",
"from",
"the",
"resultLocaleValues",
"into",
"the",
"corresponding",
"item",
"of",
"the",
"localeValues",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/extractors/CmsExtractionResult.java#L320-L334 | train |
alkacon/opencms-core | src/org/opencms/ade/galleries/shared/CmsGalleryTabConfiguration.java | CmsGalleryTabConfiguration.resolve | public static CmsGalleryTabConfiguration resolve(String configStr) {
CmsGalleryTabConfiguration tabConfig;
if (CmsStringUtil.isEmptyOrWhitespaceOnly(configStr)) {
configStr = "*sitemap,types,galleries,categories,vfstree,search,results";
}
if (DEFAULT_CONFIGURATIONS != null) {
tabConfig = DEFAULT_CONFIGURATIONS.get(configStr);
if (tabConfig != null) {
return tabConfig;
}
}
return parse(configStr);
} | java | public static CmsGalleryTabConfiguration resolve(String configStr) {
CmsGalleryTabConfiguration tabConfig;
if (CmsStringUtil.isEmptyOrWhitespaceOnly(configStr)) {
configStr = "*sitemap,types,galleries,categories,vfstree,search,results";
}
if (DEFAULT_CONFIGURATIONS != null) {
tabConfig = DEFAULT_CONFIGURATIONS.get(configStr);
if (tabConfig != null) {
return tabConfig;
}
}
return parse(configStr);
} | [
"public",
"static",
"CmsGalleryTabConfiguration",
"resolve",
"(",
"String",
"configStr",
")",
"{",
"CmsGalleryTabConfiguration",
"tabConfig",
";",
"if",
"(",
"CmsStringUtil",
".",
"isEmptyOrWhitespaceOnly",
"(",
"configStr",
")",
")",
"{",
"configStr",
"=",
"\"*sitema... | Given a string which is either the name of a predefined tab configuration or a configuration string, returns
the corresponding tab configuration.
@param configStr a configuration string or predefined configuration name
@return the gallery tab configuration | [
"Given",
"a",
"string",
"which",
"is",
"either",
"the",
"name",
"of",
"a",
"predefined",
"tab",
"configuration",
"or",
"a",
"configuration",
"string",
"returns",
"the",
"corresponding",
"tab",
"configuration",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/galleries/shared/CmsGalleryTabConfiguration.java#L181-L195 | train |
alkacon/opencms-core | src-setup/org/opencms/setup/ui/CmsSetupStep04Modules.java | CmsSetupStep04Modules.forward | private void forward() {
Set<String> selected = new HashSet<>();
for (CheckBox checkbox : m_componentCheckboxes) {
CmsSetupComponent component = (CmsSetupComponent)(checkbox.getData());
if (checkbox.getValue().booleanValue()) {
selected.add(component.getId());
}
}
String error = null;
for (String compId : selected) {
CmsSetupComponent component = m_componentMap.get(compId);
for (String dep : component.getDependencies()) {
if (!selected.contains(dep)) {
error = "Unfulfilled dependency: The component "
+ component.getName()
+ " can not be installed because its dependency "
+ m_componentMap.get(dep).getName()
+ " is not selected";
break;
}
}
}
if (error == null) {
Set<String> modules = new HashSet<>();
for (CmsSetupComponent component : m_componentMap.values()) {
if (selected.contains(component.getId())) {
for (CmsModule module : m_context.getSetupBean().getAvailableModules().values()) {
if (component.match(module.getName())) {
modules.add(module.getName());
}
}
}
}
List<String> moduleList = new ArrayList<>(modules);
m_context.getSetupBean().setInstallModules(CmsStringUtil.listAsString(moduleList, "|"));
m_context.stepForward();
} else {
CmsSetupErrorDialog.showErrorDialog(error, error);
}
} | java | private void forward() {
Set<String> selected = new HashSet<>();
for (CheckBox checkbox : m_componentCheckboxes) {
CmsSetupComponent component = (CmsSetupComponent)(checkbox.getData());
if (checkbox.getValue().booleanValue()) {
selected.add(component.getId());
}
}
String error = null;
for (String compId : selected) {
CmsSetupComponent component = m_componentMap.get(compId);
for (String dep : component.getDependencies()) {
if (!selected.contains(dep)) {
error = "Unfulfilled dependency: The component "
+ component.getName()
+ " can not be installed because its dependency "
+ m_componentMap.get(dep).getName()
+ " is not selected";
break;
}
}
}
if (error == null) {
Set<String> modules = new HashSet<>();
for (CmsSetupComponent component : m_componentMap.values()) {
if (selected.contains(component.getId())) {
for (CmsModule module : m_context.getSetupBean().getAvailableModules().values()) {
if (component.match(module.getName())) {
modules.add(module.getName());
}
}
}
}
List<String> moduleList = new ArrayList<>(modules);
m_context.getSetupBean().setInstallModules(CmsStringUtil.listAsString(moduleList, "|"));
m_context.stepForward();
} else {
CmsSetupErrorDialog.showErrorDialog(error, error);
}
} | [
"private",
"void",
"forward",
"(",
")",
"{",
"Set",
"<",
"String",
">",
"selected",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"CheckBox",
"checkbox",
":",
"m_componentCheckboxes",
")",
"{",
"CmsSetupComponent",
"component",
"=",
"(",
"CmsSetu... | Moves to the next step. | [
"Moves",
"to",
"the",
"next",
"step",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-setup/org/opencms/setup/ui/CmsSetupStep04Modules.java#L90-L134 | train |
alkacon/opencms-core | src-setup/org/opencms/setup/ui/CmsSetupStep04Modules.java | CmsSetupStep04Modules.initComponents | private void initComponents(List<CmsSetupComponent> components) {
for (CmsSetupComponent component : components) {
CheckBox checkbox = new CheckBox();
checkbox.setValue(component.isChecked());
checkbox.setCaption(component.getName() + " - " + component.getDescription());
checkbox.setDescription(component.getDescription());
checkbox.setData(component);
checkbox.setWidth("100%");
m_components.addComponent(checkbox);
m_componentCheckboxes.add(checkbox);
m_componentMap.put(component.getId(), component);
}
} | java | private void initComponents(List<CmsSetupComponent> components) {
for (CmsSetupComponent component : components) {
CheckBox checkbox = new CheckBox();
checkbox.setValue(component.isChecked());
checkbox.setCaption(component.getName() + " - " + component.getDescription());
checkbox.setDescription(component.getDescription());
checkbox.setData(component);
checkbox.setWidth("100%");
m_components.addComponent(checkbox);
m_componentCheckboxes.add(checkbox);
m_componentMap.put(component.getId(), component);
}
} | [
"private",
"void",
"initComponents",
"(",
"List",
"<",
"CmsSetupComponent",
">",
"components",
")",
"{",
"for",
"(",
"CmsSetupComponent",
"component",
":",
"components",
")",
"{",
"CheckBox",
"checkbox",
"=",
"new",
"CheckBox",
"(",
")",
";",
"checkbox",
".",
... | Initializes the components.
@param components the components | [
"Initializes",
"the",
"components",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-setup/org/opencms/setup/ui/CmsSetupStep04Modules.java#L141-L155 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/controller/CmsSearchControllerFacetQuery.java | CmsSearchControllerFacetQuery.addFacetPart | protected void addFacetPart(CmsSolrQuery query) {
query.set("facet", "true");
String excludes = "";
if (m_config.getIgnoreAllFacetFilters()
|| (!m_state.getCheckedEntries().isEmpty() && !m_config.getIsAndFacet())) {
excludes = "{!ex=" + m_config.getIgnoreTags() + "}";
}
for (I_CmsFacetQueryItem q : m_config.getQueryList()) {
query.add("facet.query", excludes + q.getQuery());
}
} | java | protected void addFacetPart(CmsSolrQuery query) {
query.set("facet", "true");
String excludes = "";
if (m_config.getIgnoreAllFacetFilters()
|| (!m_state.getCheckedEntries().isEmpty() && !m_config.getIsAndFacet())) {
excludes = "{!ex=" + m_config.getIgnoreTags() + "}";
}
for (I_CmsFacetQueryItem q : m_config.getQueryList()) {
query.add("facet.query", excludes + q.getQuery());
}
} | [
"protected",
"void",
"addFacetPart",
"(",
"CmsSolrQuery",
"query",
")",
"{",
"query",
".",
"set",
"(",
"\"facet\"",
",",
"\"true\"",
")",
";",
"String",
"excludes",
"=",
"\"\"",
";",
"if",
"(",
"m_config",
".",
"getIgnoreAllFacetFilters",
"(",
")",
"||",
"... | Add query part for the facet, without filters.
@param query The query part that is extended for the facet | [
"Add",
"query",
"part",
"for",
"the",
"facet",
"without",
"filters",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/controller/CmsSearchControllerFacetQuery.java#L140-L152 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/result/CmsSearchResultWrapper.java | CmsSearchResultWrapper.convertSearchResults | protected void convertSearchResults(final Collection<CmsSearchResource> searchResults) {
m_foundResources = new ArrayList<I_CmsSearchResourceBean>();
for (final CmsSearchResource searchResult : searchResults) {
m_foundResources.add(new CmsSearchResourceBean(searchResult, m_cmsObject));
}
} | java | protected void convertSearchResults(final Collection<CmsSearchResource> searchResults) {
m_foundResources = new ArrayList<I_CmsSearchResourceBean>();
for (final CmsSearchResource searchResult : searchResults) {
m_foundResources.add(new CmsSearchResourceBean(searchResult, m_cmsObject));
}
} | [
"protected",
"void",
"convertSearchResults",
"(",
"final",
"Collection",
"<",
"CmsSearchResource",
">",
"searchResults",
")",
"{",
"m_foundResources",
"=",
"new",
"ArrayList",
"<",
"I_CmsSearchResourceBean",
">",
"(",
")",
";",
"for",
"(",
"final",
"CmsSearchResourc... | Converts the search results from CmsSearchResource to CmsSearchResourceBean.
@param searchResults The collection of search results to transform. | [
"Converts",
"the",
"search",
"results",
"from",
"CmsSearchResource",
"to",
"CmsSearchResourceBean",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/result/CmsSearchResultWrapper.java#L487-L493 | train |
alkacon/opencms-core | src/org/opencms/site/CmsSiteManagerImpl.java | CmsSiteManagerImpl.addAliasToConfigSite | public void addAliasToConfigSite(String alias, String redirect, String offset) {
long timeOffset = 0;
try {
timeOffset = Long.parseLong(offset);
} catch (Throwable e) {
// ignore
}
CmsSiteMatcher siteMatcher = new CmsSiteMatcher(alias, timeOffset);
boolean redirectVal = new Boolean(redirect).booleanValue();
siteMatcher.setRedirect(redirectVal);
m_aliases.add(siteMatcher);
} | java | public void addAliasToConfigSite(String alias, String redirect, String offset) {
long timeOffset = 0;
try {
timeOffset = Long.parseLong(offset);
} catch (Throwable e) {
// ignore
}
CmsSiteMatcher siteMatcher = new CmsSiteMatcher(alias, timeOffset);
boolean redirectVal = new Boolean(redirect).booleanValue();
siteMatcher.setRedirect(redirectVal);
m_aliases.add(siteMatcher);
} | [
"public",
"void",
"addAliasToConfigSite",
"(",
"String",
"alias",
",",
"String",
"redirect",
",",
"String",
"offset",
")",
"{",
"long",
"timeOffset",
"=",
"0",
";",
"try",
"{",
"timeOffset",
"=",
"Long",
".",
"parseLong",
"(",
"offset",
")",
";",
"}",
"c... | Adds an alias to the currently configured site.
@param alias the URL of the alias server
@param redirect <code>true</code> to always redirect to main URL
@param offset the optional time offset for this alias | [
"Adds",
"an",
"alias",
"to",
"the",
"currently",
"configured",
"site",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/site/CmsSiteManagerImpl.java#L207-L219 | train |
alkacon/opencms-core | src/org/opencms/site/CmsSiteManagerImpl.java | CmsSiteManagerImpl.addServer | private void addServer(CmsSiteMatcher matcher, CmsSite site) {
Map<CmsSiteMatcher, CmsSite> siteMatcherSites = new HashMap<CmsSiteMatcher, CmsSite>(m_siteMatcherSites);
siteMatcherSites.put(matcher, site);
setSiteMatcherSites(siteMatcherSites);
} | java | private void addServer(CmsSiteMatcher matcher, CmsSite site) {
Map<CmsSiteMatcher, CmsSite> siteMatcherSites = new HashMap<CmsSiteMatcher, CmsSite>(m_siteMatcherSites);
siteMatcherSites.put(matcher, site);
setSiteMatcherSites(siteMatcherSites);
} | [
"private",
"void",
"addServer",
"(",
"CmsSiteMatcher",
"matcher",
",",
"CmsSite",
"site",
")",
"{",
"Map",
"<",
"CmsSiteMatcher",
",",
"CmsSite",
">",
"siteMatcherSites",
"=",
"new",
"HashMap",
"<",
"CmsSiteMatcher",
",",
"CmsSite",
">",
"(",
"m_siteMatcherSites... | Adds a new Site matcher object to the map of server names.
@param matcher the SiteMatcher of the server
@param site the site to add | [
"Adds",
"a",
"new",
"Site",
"matcher",
"object",
"to",
"the",
"map",
"of",
"server",
"names",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/site/CmsSiteManagerImpl.java#L1632-L1637 | train |
alkacon/opencms-core | src/org/opencms/ui/apps/sitemanager/CmsSitesWebserverThread.java | CmsSitesWebserverThread.updateLetsEncrypt | private void updateLetsEncrypt() {
getReport().println(Messages.get().container(Messages.RPT_STARTING_LETSENCRYPT_UPDATE_0));
CmsLetsEncryptConfiguration config = OpenCms.getLetsEncryptConfig();
if ((config == null) || !config.isValidAndEnabled()) {
return;
}
CmsSiteConfigToLetsEncryptConfigConverter converter = new CmsSiteConfigToLetsEncryptConfigConverter(config);
boolean ok = converter.run(getReport(), OpenCms.getSiteManager());
if (ok) {
getReport().println(
org.opencms.ui.apps.Messages.get().container(org.opencms.ui.apps.Messages.RPT_LETSENCRYPT_FINISHED_0),
I_CmsReport.FORMAT_OK);
}
} | java | private void updateLetsEncrypt() {
getReport().println(Messages.get().container(Messages.RPT_STARTING_LETSENCRYPT_UPDATE_0));
CmsLetsEncryptConfiguration config = OpenCms.getLetsEncryptConfig();
if ((config == null) || !config.isValidAndEnabled()) {
return;
}
CmsSiteConfigToLetsEncryptConfigConverter converter = new CmsSiteConfigToLetsEncryptConfigConverter(config);
boolean ok = converter.run(getReport(), OpenCms.getSiteManager());
if (ok) {
getReport().println(
org.opencms.ui.apps.Messages.get().container(org.opencms.ui.apps.Messages.RPT_LETSENCRYPT_FINISHED_0),
I_CmsReport.FORMAT_OK);
}
} | [
"private",
"void",
"updateLetsEncrypt",
"(",
")",
"{",
"getReport",
"(",
")",
".",
"println",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"RPT_STARTING_LETSENCRYPT_UPDATE_0",
")",
")",
";",
"CmsLetsEncryptConfiguration",
"confi... | Updates LetsEncrypt configuration. | [
"Updates",
"LetsEncrypt",
"configuration",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/sitemanager/CmsSitesWebserverThread.java#L330-L346 | train |
alkacon/opencms-core | src/org/opencms/ade/contenteditor/CmsContentService.java | CmsContentService.getDynamicAttributeValue | private String getDynamicAttributeValue(
CmsFile file,
I_CmsXmlContentValue value,
String attributeName,
CmsEntity editedLocalEntity) {
if ((null != editedLocalEntity) && (editedLocalEntity.getAttribute(attributeName) != null)) {
getSessionCache().setDynamicValue(
attributeName,
editedLocalEntity.getAttribute(attributeName).getSimpleValue());
}
String currentValue = getSessionCache().getDynamicValue(attributeName);
if (null != currentValue) {
return currentValue;
}
if (null != file) {
if (value.getTypeName().equals(CmsXmlDynamicCategoryValue.TYPE_NAME)) {
List<CmsCategory> categories = new ArrayList<CmsCategory>(0);
try {
categories = CmsCategoryService.getInstance().readResourceCategories(getCmsObject(), file);
} catch (CmsException e) {
LOG.error(Messages.get().getBundle().key(Messages.ERROR_FAILED_READING_CATEGORIES_1), e);
}
I_CmsWidget widget = null;
widget = CmsWidgetUtil.collectWidgetInfo(value).getWidget();
if ((null != widget) && (widget instanceof CmsCategoryWidget)) {
String mainCategoryPath = ((CmsCategoryWidget)widget).getStartingCategory(
getCmsObject(),
getCmsObject().getSitePath(file));
StringBuffer pathes = new StringBuffer();
for (CmsCategory category : categories) {
if (category.getPath().startsWith(mainCategoryPath)) {
String path = category.getBasePath() + category.getPath();
path = getCmsObject().getRequestContext().removeSiteRoot(path);
pathes.append(path).append(',');
}
}
String dynamicConfigString = pathes.length() > 0 ? pathes.substring(0, pathes.length() - 1) : "";
getSessionCache().setDynamicValue(attributeName, dynamicConfigString);
return dynamicConfigString;
}
}
}
return "";
} | java | private String getDynamicAttributeValue(
CmsFile file,
I_CmsXmlContentValue value,
String attributeName,
CmsEntity editedLocalEntity) {
if ((null != editedLocalEntity) && (editedLocalEntity.getAttribute(attributeName) != null)) {
getSessionCache().setDynamicValue(
attributeName,
editedLocalEntity.getAttribute(attributeName).getSimpleValue());
}
String currentValue = getSessionCache().getDynamicValue(attributeName);
if (null != currentValue) {
return currentValue;
}
if (null != file) {
if (value.getTypeName().equals(CmsXmlDynamicCategoryValue.TYPE_NAME)) {
List<CmsCategory> categories = new ArrayList<CmsCategory>(0);
try {
categories = CmsCategoryService.getInstance().readResourceCategories(getCmsObject(), file);
} catch (CmsException e) {
LOG.error(Messages.get().getBundle().key(Messages.ERROR_FAILED_READING_CATEGORIES_1), e);
}
I_CmsWidget widget = null;
widget = CmsWidgetUtil.collectWidgetInfo(value).getWidget();
if ((null != widget) && (widget instanceof CmsCategoryWidget)) {
String mainCategoryPath = ((CmsCategoryWidget)widget).getStartingCategory(
getCmsObject(),
getCmsObject().getSitePath(file));
StringBuffer pathes = new StringBuffer();
for (CmsCategory category : categories) {
if (category.getPath().startsWith(mainCategoryPath)) {
String path = category.getBasePath() + category.getPath();
path = getCmsObject().getRequestContext().removeSiteRoot(path);
pathes.append(path).append(',');
}
}
String dynamicConfigString = pathes.length() > 0 ? pathes.substring(0, pathes.length() - 1) : "";
getSessionCache().setDynamicValue(attributeName, dynamicConfigString);
return dynamicConfigString;
}
}
}
return "";
} | [
"private",
"String",
"getDynamicAttributeValue",
"(",
"CmsFile",
"file",
",",
"I_CmsXmlContentValue",
"value",
",",
"String",
"attributeName",
",",
"CmsEntity",
"editedLocalEntity",
")",
"{",
"if",
"(",
"(",
"null",
"!=",
"editedLocalEntity",
")",
"&&",
"(",
"edit... | Returns the value that has to be set for the dynamic attribute.
@param file the file where the current content is stored
@param value the content value that is represented by the attribute
@param attributeName the attribute's name
@param editedLocalEntity the entities that where edited last
@return the value that has to be set for the dynamic attribute. | [
"Returns",
"the",
"value",
"that",
"has",
"to",
"be",
"set",
"for",
"the",
"dynamic",
"attribute",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/contenteditor/CmsContentService.java#L1784-L1829 | train |
alkacon/opencms-core | src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelYearlyController.java | CmsPatternPanelYearlyController.setMonth | public void setMonth(String monthStr) {
final Month month = Month.valueOf(monthStr);
if ((m_model.getMonth() == null) || !m_model.getMonth().equals(monthStr)) {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.setMonth(month);
onValueChange();
}
});
}
} | java | public void setMonth(String monthStr) {
final Month month = Month.valueOf(monthStr);
if ((m_model.getMonth() == null) || !m_model.getMonth().equals(monthStr)) {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.setMonth(month);
onValueChange();
}
});
}
} | [
"public",
"void",
"setMonth",
"(",
"String",
"monthStr",
")",
"{",
"final",
"Month",
"month",
"=",
"Month",
".",
"valueOf",
"(",
"monthStr",
")",
";",
"if",
"(",
"(",
"m_model",
".",
"getMonth",
"(",
")",
"==",
"null",
")",
"||",
"!",
"m_model",
".",... | Set the month.
@param monthStr the month to set. | [
"Set",
"the",
"month",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelYearlyController.java#L65-L79 | train |
alkacon/opencms-core | src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelYearlyController.java | CmsPatternPanelYearlyController.setPatternScheme | public void setPatternScheme(final boolean isWeekDayBased) {
if (isWeekDayBased ^ (null != m_model.getWeekDay())) {
removeExceptionsOnChange(new Command() {
public void execute() {
if (isWeekDayBased) {
m_model.setWeekDay(getPatternDefaultValues().getWeekDay());
m_model.setWeekOfMonth(getPatternDefaultValues().getWeekOfMonth());
} else {
m_model.setWeekDay(null);
m_model.setWeekOfMonth(null);
}
m_model.setMonth(getPatternDefaultValues().getMonth());
m_model.setDayOfMonth(getPatternDefaultValues().getDayOfMonth());
m_model.setInterval(getPatternDefaultValues().getInterval());
onValueChange();
}
});
}
} | java | public void setPatternScheme(final boolean isWeekDayBased) {
if (isWeekDayBased ^ (null != m_model.getWeekDay())) {
removeExceptionsOnChange(new Command() {
public void execute() {
if (isWeekDayBased) {
m_model.setWeekDay(getPatternDefaultValues().getWeekDay());
m_model.setWeekOfMonth(getPatternDefaultValues().getWeekOfMonth());
} else {
m_model.setWeekDay(null);
m_model.setWeekOfMonth(null);
}
m_model.setMonth(getPatternDefaultValues().getMonth());
m_model.setDayOfMonth(getPatternDefaultValues().getDayOfMonth());
m_model.setInterval(getPatternDefaultValues().getInterval());
onValueChange();
}
});
}
} | [
"public",
"void",
"setPatternScheme",
"(",
"final",
"boolean",
"isWeekDayBased",
")",
"{",
"if",
"(",
"isWeekDayBased",
"^",
"(",
"null",
"!=",
"m_model",
".",
"getWeekDay",
"(",
")",
")",
")",
"{",
"removeExceptionsOnChange",
"(",
"new",
"Command",
"(",
")"... | Set the pattern scheme.
@param isWeekDayBased flag, indicating if the week day based scheme should be set. | [
"Set",
"the",
"pattern",
"scheme",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelYearlyController.java#L85-L106 | train |
alkacon/opencms-core | src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelYearlyController.java | CmsPatternPanelYearlyController.setWeekDay | public void setWeekDay(String weekDayStr) {
final WeekDay weekDay = WeekDay.valueOf(weekDayStr);
if ((m_model.getWeekDay() != null) || !m_model.getWeekDay().equals(weekDay)) {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.setWeekDay(weekDay);
onValueChange();
}
});
}
} | java | public void setWeekDay(String weekDayStr) {
final WeekDay weekDay = WeekDay.valueOf(weekDayStr);
if ((m_model.getWeekDay() != null) || !m_model.getWeekDay().equals(weekDay)) {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.setWeekDay(weekDay);
onValueChange();
}
});
}
} | [
"public",
"void",
"setWeekDay",
"(",
"String",
"weekDayStr",
")",
"{",
"final",
"WeekDay",
"weekDay",
"=",
"WeekDay",
".",
"valueOf",
"(",
"weekDayStr",
")",
";",
"if",
"(",
"(",
"m_model",
".",
"getWeekDay",
"(",
")",
"!=",
"null",
")",
"||",
"!",
"m_... | Set the week day.
@param weekDayStr the week day to set. | [
"Set",
"the",
"week",
"day",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelYearlyController.java#L112-L127 | train |
alkacon/opencms-core | src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelYearlyController.java | CmsPatternPanelYearlyController.setWeekOfMonth | public void setWeekOfMonth(String weekOfMonthStr) {
final WeekOfMonth weekOfMonth = WeekOfMonth.valueOf(weekOfMonthStr);
if ((null == m_model.getWeekOfMonth()) || !m_model.getWeekOfMonth().equals(weekOfMonth)) {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.setWeekOfMonth(weekOfMonth);
onValueChange();
}
});
}
} | java | public void setWeekOfMonth(String weekOfMonthStr) {
final WeekOfMonth weekOfMonth = WeekOfMonth.valueOf(weekOfMonthStr);
if ((null == m_model.getWeekOfMonth()) || !m_model.getWeekOfMonth().equals(weekOfMonth)) {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.setWeekOfMonth(weekOfMonth);
onValueChange();
}
});
}
} | [
"public",
"void",
"setWeekOfMonth",
"(",
"String",
"weekOfMonthStr",
")",
"{",
"final",
"WeekOfMonth",
"weekOfMonth",
"=",
"WeekOfMonth",
".",
"valueOf",
"(",
"weekOfMonthStr",
")",
";",
"if",
"(",
"(",
"null",
"==",
"m_model",
".",
"getWeekOfMonth",
"(",
")",... | Set the week of month.
@param weekOfMonthStr the week of month to set. | [
"Set",
"the",
"week",
"of",
"month",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelYearlyController.java#L133-L147 | train |
alkacon/opencms-core | src/org/opencms/file/CmsProperty.java | CmsProperty.getLocalizedKey | public static String getLocalizedKey(Map<String, ?> propertiesMap, String key, Locale locale) {
List<String> localizedKeys = CmsLocaleManager.getLocaleVariants(key, locale, true, false);
for (String localizedKey : localizedKeys) {
if (propertiesMap.containsKey(localizedKey)) {
return localizedKey;
}
}
return key;
} | java | public static String getLocalizedKey(Map<String, ?> propertiesMap, String key, Locale locale) {
List<String> localizedKeys = CmsLocaleManager.getLocaleVariants(key, locale, true, false);
for (String localizedKey : localizedKeys) {
if (propertiesMap.containsKey(localizedKey)) {
return localizedKey;
}
}
return key;
} | [
"public",
"static",
"String",
"getLocalizedKey",
"(",
"Map",
"<",
"String",
",",
"?",
">",
"propertiesMap",
",",
"String",
"key",
",",
"Locale",
"locale",
")",
"{",
"List",
"<",
"String",
">",
"localizedKeys",
"=",
"CmsLocaleManager",
".",
"getLocaleVariants",... | Returns the key for the best matching local-specific property version.
@param propertiesMap the "raw" property map
@param key the name of the property to search for
@param locale the locale to search for
@return the key for the best matching local-specific property version. | [
"Returns",
"the",
"key",
"for",
"the",
"best",
"matching",
"local",
"-",
"specific",
"property",
"version",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/file/CmsProperty.java#L328-L337 | train |
alkacon/opencms-core | src-modules/org/opencms/workplace/tools/searchindex/CmsFieldsList.java | CmsFieldsList.getFields | private List<CmsSearchField> getFields() {
CmsSearchManager manager = OpenCms.getSearchManager();
I_CmsSearchFieldConfiguration fieldConfig = manager.getFieldConfiguration(getParamFieldconfiguration());
List<CmsSearchField> result;
if (fieldConfig != null) {
result = fieldConfig.getFields();
} else {
result = Collections.emptyList();
if (LOG.isErrorEnabled()) {
LOG.error(
Messages.get().getBundle().key(
Messages.ERR_SEARCHINDEX_EDIT_MISSING_PARAM_1,
A_CmsFieldConfigurationDialog.PARAM_FIELDCONFIGURATION));
}
}
return result;
} | java | private List<CmsSearchField> getFields() {
CmsSearchManager manager = OpenCms.getSearchManager();
I_CmsSearchFieldConfiguration fieldConfig = manager.getFieldConfiguration(getParamFieldconfiguration());
List<CmsSearchField> result;
if (fieldConfig != null) {
result = fieldConfig.getFields();
} else {
result = Collections.emptyList();
if (LOG.isErrorEnabled()) {
LOG.error(
Messages.get().getBundle().key(
Messages.ERR_SEARCHINDEX_EDIT_MISSING_PARAM_1,
A_CmsFieldConfigurationDialog.PARAM_FIELDCONFIGURATION));
}
}
return result;
} | [
"private",
"List",
"<",
"CmsSearchField",
">",
"getFields",
"(",
")",
"{",
"CmsSearchManager",
"manager",
"=",
"OpenCms",
".",
"getSearchManager",
"(",
")",
";",
"I_CmsSearchFieldConfiguration",
"fieldConfig",
"=",
"manager",
".",
"getFieldConfiguration",
"(",
"getP... | Returns the configured fields of the current field configuration.
@return the configured fields of the current field configuration | [
"Returns",
"the",
"configured",
"fields",
"of",
"the",
"current",
"field",
"configuration",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/searchindex/CmsFieldsList.java#L720-L737 | train |
alkacon/opencms-core | src/org/opencms/ade/containerpage/CmsElementUtil.java | CmsElementUtil.createStringTemplateSource | public static Function<String, String> createStringTemplateSource(
I_CmsFormatterBean formatter,
Supplier<CmsXmlContent> contentSupplier) {
return key -> {
String result = null;
if (formatter != null) {
result = formatter.getAttributes().get(key);
}
if (result == null) {
CmsXmlContent content = contentSupplier.get();
if (content != null) {
result = content.getHandler().getParameter(key);
}
}
return result;
};
} | java | public static Function<String, String> createStringTemplateSource(
I_CmsFormatterBean formatter,
Supplier<CmsXmlContent> contentSupplier) {
return key -> {
String result = null;
if (formatter != null) {
result = formatter.getAttributes().get(key);
}
if (result == null) {
CmsXmlContent content = contentSupplier.get();
if (content != null) {
result = content.getHandler().getParameter(key);
}
}
return result;
};
} | [
"public",
"static",
"Function",
"<",
"String",
",",
"String",
">",
"createStringTemplateSource",
"(",
"I_CmsFormatterBean",
"formatter",
",",
"Supplier",
"<",
"CmsXmlContent",
">",
"contentSupplier",
")",
"{",
"return",
"key",
"->",
"{",
"String",
"result",
"=",
... | Helper method to create a string template source for a given formatter and content.
@param formatter the formatter
@param contentSupplier the content supplier
@return the string template provider | [
"Helper",
"method",
"to",
"create",
"a",
"string",
"template",
"source",
"for",
"a",
"given",
"formatter",
"and",
"content",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/containerpage/CmsElementUtil.java#L297-L314 | train |
alkacon/opencms-core | src/org/opencms/ade/containerpage/CmsElementUtil.java | CmsElementUtil.getContentsByContainerName | private Map<String, String> getContentsByContainerName(
CmsContainerElementBean element,
Collection<CmsContainer> containers) {
CmsFormatterConfiguration configs = getFormatterConfiguration(element.getResource());
Map<String, String> result = new HashMap<String, String>();
for (CmsContainer container : containers) {
String content = getContentByContainer(element, container, configs);
if (content != null) {
content = removeScriptTags(content);
}
result.put(container.getName(), content);
}
return result;
} | java | private Map<String, String> getContentsByContainerName(
CmsContainerElementBean element,
Collection<CmsContainer> containers) {
CmsFormatterConfiguration configs = getFormatterConfiguration(element.getResource());
Map<String, String> result = new HashMap<String, String>();
for (CmsContainer container : containers) {
String content = getContentByContainer(element, container, configs);
if (content != null) {
content = removeScriptTags(content);
}
result.put(container.getName(), content);
}
return result;
} | [
"private",
"Map",
"<",
"String",
",",
"String",
">",
"getContentsByContainerName",
"(",
"CmsContainerElementBean",
"element",
",",
"Collection",
"<",
"CmsContainer",
">",
"containers",
")",
"{",
"CmsFormatterConfiguration",
"configs",
"=",
"getFormatterConfiguration",
"... | Returns the rendered element content for all the given containers.
@param element the element to render
@param containers the containers the element appears in
@return a map from container names to rendered page contents | [
"Returns",
"the",
"rendered",
"element",
"content",
"for",
"all",
"the",
"given",
"containers",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/containerpage/CmsElementUtil.java#L1007-L1021 | train |
alkacon/opencms-core | src-setup/org/opencms/setup/ui/CmsSetupStep03Database.java | CmsSetupStep03Database.setWorkConnection | public void setWorkConnection(CmsSetupDb db) {
db.setConnection(
m_setupBean.getDbDriver(),
m_setupBean.getDbWorkConStr(),
m_setupBean.getDbConStrParams(),
m_setupBean.getDbWorkUser(),
m_setupBean.getDbWorkPwd());
} | java | public void setWorkConnection(CmsSetupDb db) {
db.setConnection(
m_setupBean.getDbDriver(),
m_setupBean.getDbWorkConStr(),
m_setupBean.getDbConStrParams(),
m_setupBean.getDbWorkUser(),
m_setupBean.getDbWorkPwd());
} | [
"public",
"void",
"setWorkConnection",
"(",
"CmsSetupDb",
"db",
")",
"{",
"db",
".",
"setConnection",
"(",
"m_setupBean",
".",
"getDbDriver",
"(",
")",
",",
"m_setupBean",
".",
"getDbWorkConStr",
"(",
")",
",",
"m_setupBean",
".",
"getDbConStrParams",
"(",
")"... | Set work connection.
@param db the db setup bean | [
"Set",
"work",
"connection",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-setup/org/opencms/setup/ui/CmsSetupStep03Database.java#L297-L305 | train |
alkacon/opencms-core | src-setup/org/opencms/setup/ui/CmsSetupStep03Database.java | CmsSetupStep03Database.updateDb | private void updateDb(String dbName, String webapp) {
m_mainLayout.removeAllComponents();
m_setupBean.setDatabase(dbName);
CmsDbSettingsPanel panel = new CmsDbSettingsPanel(m_setupBean);
m_panel[0] = panel;
panel.initFromSetupBean(webapp);
m_mainLayout.addComponent(panel);
} | java | private void updateDb(String dbName, String webapp) {
m_mainLayout.removeAllComponents();
m_setupBean.setDatabase(dbName);
CmsDbSettingsPanel panel = new CmsDbSettingsPanel(m_setupBean);
m_panel[0] = panel;
panel.initFromSetupBean(webapp);
m_mainLayout.addComponent(panel);
} | [
"private",
"void",
"updateDb",
"(",
"String",
"dbName",
",",
"String",
"webapp",
")",
"{",
"m_mainLayout",
".",
"removeAllComponents",
"(",
")",
";",
"m_setupBean",
".",
"setDatabase",
"(",
"dbName",
")",
";",
"CmsDbSettingsPanel",
"panel",
"=",
"new",
"CmsDbS... | Switches DB type.
@param dbName the database type
@param webapp the webapp name | [
"Switches",
"DB",
"type",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-setup/org/opencms/setup/ui/CmsSetupStep03Database.java#L334-L342 | train |
alkacon/opencms-core | src/org/opencms/search/solr/CmsSolrQuery.java | CmsSolrQuery.removeExpiration | public void removeExpiration() {
if (getFilterQueries() != null) {
for (String fq : getFilterQueries()) {
if (fq.startsWith(CmsSearchField.FIELD_DATE_EXPIRED + ":")
|| fq.startsWith(CmsSearchField.FIELD_DATE_RELEASED + ":")) {
removeFilterQuery(fq);
}
}
}
m_ignoreExpiration = true;
} | java | public void removeExpiration() {
if (getFilterQueries() != null) {
for (String fq : getFilterQueries()) {
if (fq.startsWith(CmsSearchField.FIELD_DATE_EXPIRED + ":")
|| fq.startsWith(CmsSearchField.FIELD_DATE_RELEASED + ":")) {
removeFilterQuery(fq);
}
}
}
m_ignoreExpiration = true;
} | [
"public",
"void",
"removeExpiration",
"(",
")",
"{",
"if",
"(",
"getFilterQueries",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"fq",
":",
"getFilterQueries",
"(",
")",
")",
"{",
"if",
"(",
"fq",
".",
"startsWith",
"(",
"CmsSearchField",
".... | Removes the expiration flag. | [
"Removes",
"the",
"expiration",
"flag",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/CmsSolrQuery.java#L272-L283 | train |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspStandardContextBean.java | CmsJspStandardContextBean.getReadAllSubCategories | public Map<String, CmsJspCategoryAccessBean> getReadAllSubCategories() {
if (null == m_allSubCategories) {
m_allSubCategories = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() {
@Override
public Object transform(Object categoryPath) {
try {
List<CmsCategory> categories = CmsCategoryService.getInstance().readCategories(
m_cms,
(String)categoryPath,
true,
m_cms.getRequestContext().getUri());
CmsJspCategoryAccessBean result = new CmsJspCategoryAccessBean(
m_cms,
categories,
(String)categoryPath);
return result;
} catch (CmsException e) {
LOG.warn(e.getLocalizedMessage(), e);
return null;
}
}
});
}
return m_allSubCategories;
} | java | public Map<String, CmsJspCategoryAccessBean> getReadAllSubCategories() {
if (null == m_allSubCategories) {
m_allSubCategories = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() {
@Override
public Object transform(Object categoryPath) {
try {
List<CmsCategory> categories = CmsCategoryService.getInstance().readCategories(
m_cms,
(String)categoryPath,
true,
m_cms.getRequestContext().getUri());
CmsJspCategoryAccessBean result = new CmsJspCategoryAccessBean(
m_cms,
categories,
(String)categoryPath);
return result;
} catch (CmsException e) {
LOG.warn(e.getLocalizedMessage(), e);
return null;
}
}
});
}
return m_allSubCategories;
} | [
"public",
"Map",
"<",
"String",
",",
"CmsJspCategoryAccessBean",
">",
"getReadAllSubCategories",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"m_allSubCategories",
")",
"{",
"m_allSubCategories",
"=",
"CmsCollectionsGenericWrapper",
".",
"createLazyMap",
"(",
"new",
"Tra... | Reads all sub-categories below the provided category.
@return The map from the provided category to it's sub-categories in a {@link CmsJspCategoryAccessBean}. | [
"Reads",
"all",
"sub",
"-",
"categories",
"below",
"the",
"provided",
"category",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspStandardContextBean.java#L1409-L1437 | train |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspStandardContextBean.java | CmsJspStandardContextBean.getReadCategory | public Map<String, CmsCategory> getReadCategory() {
if (null == m_categories) {
m_categories = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() {
public Object transform(Object categoryPath) {
try {
CmsCategoryService catService = CmsCategoryService.getInstance();
return catService.localizeCategory(
m_cms,
catService.readCategory(m_cms, (String)categoryPath, getRequestContext().getUri()),
m_cms.getRequestContext().getLocale());
} catch (CmsException e) {
LOG.warn(e.getLocalizedMessage(), e);
return null;
}
}
});
}
return m_categories;
} | java | public Map<String, CmsCategory> getReadCategory() {
if (null == m_categories) {
m_categories = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() {
public Object transform(Object categoryPath) {
try {
CmsCategoryService catService = CmsCategoryService.getInstance();
return catService.localizeCategory(
m_cms,
catService.readCategory(m_cms, (String)categoryPath, getRequestContext().getUri()),
m_cms.getRequestContext().getLocale());
} catch (CmsException e) {
LOG.warn(e.getLocalizedMessage(), e);
return null;
}
}
});
}
return m_categories;
} | [
"public",
"Map",
"<",
"String",
",",
"CmsCategory",
">",
"getReadCategory",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"m_categories",
")",
"{",
"m_categories",
"=",
"CmsCollectionsGenericWrapper",
".",
"createLazyMap",
"(",
"new",
"Transformer",
"(",
")",
"{",
... | Transforms the category path of a category to the category.
@return a map from root or site path to category. | [
"Transforms",
"the",
"category",
"path",
"of",
"a",
"category",
"to",
"the",
"category",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspStandardContextBean.java#L1452-L1474 | train |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspStandardContextBean.java | CmsJspStandardContextBean.getReadResourceCategories | public Map<String, CmsJspCategoryAccessBean> getReadResourceCategories() {
if (null == m_resourceCategories) {
m_resourceCategories = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() {
public Object transform(Object resourceName) {
try {
CmsResource resource = m_cms.readResource(
getRequestContext().removeSiteRoot((String)resourceName));
return new CmsJspCategoryAccessBean(m_cms, resource);
} catch (CmsException e) {
LOG.warn(e.getLocalizedMessage(), e);
return null;
}
}
});
}
return m_resourceCategories;
} | java | public Map<String, CmsJspCategoryAccessBean> getReadResourceCategories() {
if (null == m_resourceCategories) {
m_resourceCategories = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() {
public Object transform(Object resourceName) {
try {
CmsResource resource = m_cms.readResource(
getRequestContext().removeSiteRoot((String)resourceName));
return new CmsJspCategoryAccessBean(m_cms, resource);
} catch (CmsException e) {
LOG.warn(e.getLocalizedMessage(), e);
return null;
}
}
});
}
return m_resourceCategories;
} | [
"public",
"Map",
"<",
"String",
",",
"CmsJspCategoryAccessBean",
">",
"getReadResourceCategories",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"m_resourceCategories",
")",
"{",
"m_resourceCategories",
"=",
"CmsCollectionsGenericWrapper",
".",
"createLazyMap",
"(",
"new",
... | Reads the categories assigned to a resource.
@return map from the resource path (root path) to the assigned categories | [
"Reads",
"the",
"categories",
"assigned",
"to",
"a",
"resource",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspStandardContextBean.java#L1528-L1547 | train |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspStandardContextBean.java | CmsJspStandardContextBean.getSitePath | public Map<String, String> getSitePath() {
if (m_sitePaths == null) {
m_sitePaths = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() {
public Object transform(Object rootPath) {
if (rootPath instanceof String) {
return getRequestContext().removeSiteRoot((String)rootPath);
}
return null;
}
});
}
return m_sitePaths;
} | java | public Map<String, String> getSitePath() {
if (m_sitePaths == null) {
m_sitePaths = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() {
public Object transform(Object rootPath) {
if (rootPath instanceof String) {
return getRequestContext().removeSiteRoot((String)rootPath);
}
return null;
}
});
}
return m_sitePaths;
} | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"getSitePath",
"(",
")",
"{",
"if",
"(",
"m_sitePaths",
"==",
"null",
")",
"{",
"m_sitePaths",
"=",
"CmsCollectionsGenericWrapper",
".",
"createLazyMap",
"(",
"new",
"Transformer",
"(",
")",
"{",
"public",
... | Transforms root paths to site paths.
@return lazy map from root paths to site paths.
@see CmsRequestContext#removeSiteRoot(String) | [
"Transforms",
"root",
"paths",
"to",
"site",
"paths",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspStandardContextBean.java#L1591-L1606 | train |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspStandardContextBean.java | CmsJspStandardContextBean.getTitleLocale | public Map<String, String> getTitleLocale() {
if (m_localeTitles == null) {
m_localeTitles = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() {
public Object transform(Object inputLocale) {
Locale locale = null;
if (null != inputLocale) {
if (inputLocale instanceof Locale) {
locale = (Locale)inputLocale;
} else if (inputLocale instanceof String) {
try {
locale = LocaleUtils.toLocale((String)inputLocale);
} catch (IllegalArgumentException | NullPointerException e) {
// do nothing, just go on without locale
}
}
}
return getLocaleSpecificTitle(locale);
}
});
}
return m_localeTitles;
} | java | public Map<String, String> getTitleLocale() {
if (m_localeTitles == null) {
m_localeTitles = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() {
public Object transform(Object inputLocale) {
Locale locale = null;
if (null != inputLocale) {
if (inputLocale instanceof Locale) {
locale = (Locale)inputLocale;
} else if (inputLocale instanceof String) {
try {
locale = LocaleUtils.toLocale((String)inputLocale);
} catch (IllegalArgumentException | NullPointerException e) {
// do nothing, just go on without locale
}
}
}
return getLocaleSpecificTitle(locale);
}
});
}
return m_localeTitles;
} | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"getTitleLocale",
"(",
")",
"{",
"if",
"(",
"m_localeTitles",
"==",
"null",
")",
"{",
"m_localeTitles",
"=",
"CmsCollectionsGenericWrapper",
".",
"createLazyMap",
"(",
"new",
"Transformer",
"(",
")",
"{",
"... | Get the title and read the Title property according the provided locale.
@return The map from locales to the locale specific titles. | [
"Get",
"the",
"title",
"and",
"read",
"the",
"Title",
"property",
"according",
"the",
"provided",
"locale",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspStandardContextBean.java#L1661-L1686 | train |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspStandardContextBean.java | CmsJspStandardContextBean.getLocaleSpecificTitle | protected String getLocaleSpecificTitle(Locale locale) {
String result = null;
try {
if (isDetailRequest()) {
// this is a request to a detail page
CmsResource res = getDetailContent();
CmsFile file = m_cms.readFile(res);
CmsXmlContent content = CmsXmlContentFactory.unmarshal(m_cms, file);
result = content.getHandler().getTitleMapping(m_cms, content, m_cms.getRequestContext().getLocale());
if (result == null) {
// title not found, maybe no mapping OR not available in the current locale
// read the title of the detail resource as fall back (may contain mapping from another locale)
result = m_cms.readPropertyObject(
res,
CmsPropertyDefinition.PROPERTY_TITLE,
false,
locale).getValue();
}
}
if (result == null) {
// read the title of the requested resource as fall back
result = m_cms.readPropertyObject(
m_cms.getRequestContext().getUri(),
CmsPropertyDefinition.PROPERTY_TITLE,
true,
locale).getValue();
}
} catch (CmsException e) {
LOG.debug(e.getLocalizedMessage(), e);
}
if (CmsStringUtil.isEmptyOrWhitespaceOnly(result)) {
result = "";
}
return result;
} | java | protected String getLocaleSpecificTitle(Locale locale) {
String result = null;
try {
if (isDetailRequest()) {
// this is a request to a detail page
CmsResource res = getDetailContent();
CmsFile file = m_cms.readFile(res);
CmsXmlContent content = CmsXmlContentFactory.unmarshal(m_cms, file);
result = content.getHandler().getTitleMapping(m_cms, content, m_cms.getRequestContext().getLocale());
if (result == null) {
// title not found, maybe no mapping OR not available in the current locale
// read the title of the detail resource as fall back (may contain mapping from another locale)
result = m_cms.readPropertyObject(
res,
CmsPropertyDefinition.PROPERTY_TITLE,
false,
locale).getValue();
}
}
if (result == null) {
// read the title of the requested resource as fall back
result = m_cms.readPropertyObject(
m_cms.getRequestContext().getUri(),
CmsPropertyDefinition.PROPERTY_TITLE,
true,
locale).getValue();
}
} catch (CmsException e) {
LOG.debug(e.getLocalizedMessage(), e);
}
if (CmsStringUtil.isEmptyOrWhitespaceOnly(result)) {
result = "";
}
return result;
} | [
"protected",
"String",
"getLocaleSpecificTitle",
"(",
"Locale",
"locale",
")",
"{",
"String",
"result",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"isDetailRequest",
"(",
")",
")",
"{",
"// this is a request to a detail page",
"CmsResource",
"res",
"=",
"getDetailCo... | Returns the title according to the given locale.
@param locale the locale for which the title should be read.
@return the title according to the given locale | [
"Returns",
"the",
"title",
"according",
"to",
"the",
"given",
"locale",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspStandardContextBean.java#L2010-L2048 | train |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/ui/input/location/CmsLocationController.java | CmsLocationController.setStringValue | public void setStringValue(String value) {
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(value)) {
try {
m_editValue = CmsLocationValue.parse(value);
m_currentValue = m_editValue.cloneValue();
displayValue();
if ((m_popup != null) && m_popup.isVisible()) {
m_popupContent.displayValues(m_editValue);
updateMarkerPosition();
}
} catch (Exception e) {
CmsLog.log(e.getLocalizedMessage() + "\n" + CmsClientStringUtil.getStackTrace(e, "\n"));
}
} else {
m_currentValue = null;
displayValue();
}
} | java | public void setStringValue(String value) {
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(value)) {
try {
m_editValue = CmsLocationValue.parse(value);
m_currentValue = m_editValue.cloneValue();
displayValue();
if ((m_popup != null) && m_popup.isVisible()) {
m_popupContent.displayValues(m_editValue);
updateMarkerPosition();
}
} catch (Exception e) {
CmsLog.log(e.getLocalizedMessage() + "\n" + CmsClientStringUtil.getStackTrace(e, "\n"));
}
} else {
m_currentValue = null;
displayValue();
}
} | [
"public",
"void",
"setStringValue",
"(",
"String",
"value",
")",
"{",
"if",
"(",
"CmsStringUtil",
".",
"isNotEmptyOrWhitespaceOnly",
"(",
"value",
")",
")",
"{",
"try",
"{",
"m_editValue",
"=",
"CmsLocationValue",
".",
"parse",
"(",
"value",
")",
";",
"m_cur... | Sets the location value as string.
@param value the string representation of the location value (JSON) | [
"Sets",
"the",
"location",
"value",
"as",
"string",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/input/location/CmsLocationController.java#L235-L253 | train |
alkacon/opencms-core | src/org/opencms/jlan/CmsJlanUsers.java | CmsJlanUsers.hashPassword | public static byte[] hashPassword(String password) throws InvalidKeyException, NoSuchAlgorithmException {
PasswordEncryptor encryptor = new PasswordEncryptor();
return encryptor.generateEncryptedPassword(password, null, PasswordEncryptor.MD4, null, null);
} | java | public static byte[] hashPassword(String password) throws InvalidKeyException, NoSuchAlgorithmException {
PasswordEncryptor encryptor = new PasswordEncryptor();
return encryptor.generateEncryptedPassword(password, null, PasswordEncryptor.MD4, null, null);
} | [
"public",
"static",
"byte",
"[",
"]",
"hashPassword",
"(",
"String",
"password",
")",
"throws",
"InvalidKeyException",
",",
"NoSuchAlgorithmException",
"{",
"PasswordEncryptor",
"encryptor",
"=",
"new",
"PasswordEncryptor",
"(",
")",
";",
"return",
"encryptor",
".",... | Computes an MD4 hash for the password.
@param password the password for which to compute the hash
@throws NoSuchAlgorithmException
@throws InvalidKeyException
@return the password hash | [
"Computes",
"an",
"MD4",
"hash",
"for",
"the",
"password",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jlan/CmsJlanUsers.java#L81-L85 | train |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/super_src/com/google/gwt/http/client/RequestBuilder.java | RequestBuilder.setHeader | public void setHeader(String header, String value) {
StringValidator.throwIfEmptyOrNull("header", header);
StringValidator.throwIfEmptyOrNull("value", value);
if (headers == null) {
headers = new HashMap<String, String>();
}
headers.put(header, value);
} | java | public void setHeader(String header, String value) {
StringValidator.throwIfEmptyOrNull("header", header);
StringValidator.throwIfEmptyOrNull("value", value);
if (headers == null) {
headers = new HashMap<String, String>();
}
headers.put(header, value);
} | [
"public",
"void",
"setHeader",
"(",
"String",
"header",
",",
"String",
"value",
")",
"{",
"StringValidator",
".",
"throwIfEmptyOrNull",
"(",
"\"header\"",
",",
"header",
")",
";",
"StringValidator",
".",
"throwIfEmptyOrNull",
"(",
"\"value\"",
",",
"value",
")",... | Sets a request header with the given name and value. If a header with the
specified name has already been set then the new value overwrites the
current value.
@param header the name of the header
@param value the value of the header
@throws NullPointerException if header or value are null
@throws IllegalArgumentException if header or value are the empty string | [
"Sets",
"a",
"request",
"header",
"with",
"the",
"given",
"name",
"and",
"value",
".",
"If",
"a",
"header",
"with",
"the",
"specified",
"name",
"has",
"already",
"been",
"set",
"then",
"the",
"new",
"value",
"overwrites",
"the",
"current",
"value",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/super_src/com/google/gwt/http/client/RequestBuilder.java#L283-L292 | train |
alkacon/opencms-core | src/org/opencms/db/CmsPublishList.java | CmsPublishList.getTopFolders | protected List<CmsResource> getTopFolders(List<CmsResource> folders) {
List<String> folderPaths = new ArrayList<String>();
List<CmsResource> topFolders = new ArrayList<CmsResource>();
Map<String, CmsResource> foldersByPath = new HashMap<String, CmsResource>();
for (CmsResource folder : folders) {
folderPaths.add(folder.getRootPath());
foldersByPath.put(folder.getRootPath(), folder);
}
Collections.sort(folderPaths);
Set<String> topFolderPaths = new HashSet<String>(folderPaths);
for (int i = 0; i < folderPaths.size(); i++) {
for (int j = i + 1; j < folderPaths.size(); j++) {
if (folderPaths.get(j).startsWith((folderPaths.get(i)))) {
topFolderPaths.remove(folderPaths.get(j));
} else {
break;
}
}
}
for (String path : topFolderPaths) {
topFolders.add(foldersByPath.get(path));
}
return topFolders;
} | java | protected List<CmsResource> getTopFolders(List<CmsResource> folders) {
List<String> folderPaths = new ArrayList<String>();
List<CmsResource> topFolders = new ArrayList<CmsResource>();
Map<String, CmsResource> foldersByPath = new HashMap<String, CmsResource>();
for (CmsResource folder : folders) {
folderPaths.add(folder.getRootPath());
foldersByPath.put(folder.getRootPath(), folder);
}
Collections.sort(folderPaths);
Set<String> topFolderPaths = new HashSet<String>(folderPaths);
for (int i = 0; i < folderPaths.size(); i++) {
for (int j = i + 1; j < folderPaths.size(); j++) {
if (folderPaths.get(j).startsWith((folderPaths.get(i)))) {
topFolderPaths.remove(folderPaths.get(j));
} else {
break;
}
}
}
for (String path : topFolderPaths) {
topFolders.add(foldersByPath.get(path));
}
return topFolders;
} | [
"protected",
"List",
"<",
"CmsResource",
">",
"getTopFolders",
"(",
"List",
"<",
"CmsResource",
">",
"folders",
")",
"{",
"List",
"<",
"String",
">",
"folderPaths",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"List",
"<",
"CmsResource",
"... | Gives the "roots" of a list of folders, i.e. the list of folders which are not descendants of any other folders in the original list
@param folders the original list of folders
@return the root folders of the list | [
"Gives",
"the",
"roots",
"of",
"a",
"list",
"of",
"folders",
"i",
".",
"e",
".",
"the",
"list",
"of",
"folders",
"which",
"are",
"not",
"descendants",
"of",
"any",
"other",
"folders",
"in",
"the",
"original",
"list"
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsPublishList.java#L698-L722 | train |
alkacon/opencms-core | src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelIndividualController.java | CmsPatternPanelIndividualController.setDates | public void setDates(SortedSet<Date> dates) {
if (!m_model.getIndividualDates().equals(dates)) {
m_model.setIndividualDates(dates);
onValueChange();
}
} | java | public void setDates(SortedSet<Date> dates) {
if (!m_model.getIndividualDates().equals(dates)) {
m_model.setIndividualDates(dates);
onValueChange();
}
} | [
"public",
"void",
"setDates",
"(",
"SortedSet",
"<",
"Date",
">",
"dates",
")",
"{",
"if",
"(",
"!",
"m_model",
".",
"getIndividualDates",
"(",
")",
".",
"equals",
"(",
"dates",
")",
")",
"{",
"m_model",
".",
"setIndividualDates",
"(",
"dates",
")",
";... | Set the individual dates.
@param dates the dates to set. | [
"Set",
"the",
"individual",
"dates",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/acacia/client/widgets/serialdate/CmsPatternPanelIndividualController.java#L62-L69 | train |
alkacon/opencms-core | src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java | CmsSolrSpellchecker.getInstance | public static CmsSolrSpellchecker getInstance(CoreContainer container) {
if (null == instance) {
synchronized (CmsSolrSpellchecker.class) {
if (null == instance) {
@SuppressWarnings("resource")
SolrCore spellcheckCore = container.getCore(CmsSolrSpellchecker.SPELLCHECKER_INDEX_CORE);
if (spellcheckCore == null) {
LOG.error(
Messages.get().getBundle().key(
Messages.ERR_SPELLCHECK_CORE_NOT_AVAILABLE_1,
CmsSolrSpellchecker.SPELLCHECKER_INDEX_CORE));
return null;
}
instance = new CmsSolrSpellchecker(container, spellcheckCore);
}
}
}
return instance;
} | java | public static CmsSolrSpellchecker getInstance(CoreContainer container) {
if (null == instance) {
synchronized (CmsSolrSpellchecker.class) {
if (null == instance) {
@SuppressWarnings("resource")
SolrCore spellcheckCore = container.getCore(CmsSolrSpellchecker.SPELLCHECKER_INDEX_CORE);
if (spellcheckCore == null) {
LOG.error(
Messages.get().getBundle().key(
Messages.ERR_SPELLCHECK_CORE_NOT_AVAILABLE_1,
CmsSolrSpellchecker.SPELLCHECKER_INDEX_CORE));
return null;
}
instance = new CmsSolrSpellchecker(container, spellcheckCore);
}
}
}
return instance;
} | [
"public",
"static",
"CmsSolrSpellchecker",
"getInstance",
"(",
"CoreContainer",
"container",
")",
"{",
"if",
"(",
"null",
"==",
"instance",
")",
"{",
"synchronized",
"(",
"CmsSolrSpellchecker",
".",
"class",
")",
"{",
"if",
"(",
"null",
"==",
"instance",
")",
... | Return an instance of this class.
@param container Solr CoreContainer container object in order to create a server object.
@return instance of CmsSolrSpellchecker | [
"Return",
"an",
"instance",
"of",
"this",
"class",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java#L155-L175 | train |
alkacon/opencms-core | src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java | CmsSolrSpellchecker.getSpellcheckingResult | public void getSpellcheckingResult(
final HttpServletResponse res,
final ServletRequest servletRequest,
final CmsObject cms)
throws CmsPermissionViolationException, IOException {
// Perform a permission check
performPermissionCheck(cms);
// Set the appropriate response headers
setResponeHeaders(res);
// Figure out whether a JSON or HTTP request has been sent
CmsSpellcheckingRequest cmsSpellcheckingRequest = null;
try {
String requestBody = getRequestBody(servletRequest);
final JSONObject jsonRequest = new JSONObject(requestBody);
cmsSpellcheckingRequest = parseJsonRequest(jsonRequest);
} catch (Exception e) {
LOG.debug(e.getMessage(), e);
cmsSpellcheckingRequest = parseHttpRequest(servletRequest, cms);
}
if ((null != cmsSpellcheckingRequest) && cmsSpellcheckingRequest.isInitialized()) {
// Perform the actual spellchecking
final SpellCheckResponse spellCheckResponse = performSpellcheckQuery(cmsSpellcheckingRequest);
/*
* The field spellCheckResponse is null when exactly one correctly spelled word is passed to the spellchecker.
* In this case it's safe to return an empty JSON formatted map, as the passed word is correct. Otherwise,
* convert the spellchecker response into a new JSON formatted map.
*/
if (null == spellCheckResponse) {
cmsSpellcheckingRequest.m_wordSuggestions = new JSONObject();
} else {
cmsSpellcheckingRequest.m_wordSuggestions = getConvertedResponseAsJson(spellCheckResponse);
}
}
// Send response back to the client
sendResponse(res, cmsSpellcheckingRequest);
} | java | public void getSpellcheckingResult(
final HttpServletResponse res,
final ServletRequest servletRequest,
final CmsObject cms)
throws CmsPermissionViolationException, IOException {
// Perform a permission check
performPermissionCheck(cms);
// Set the appropriate response headers
setResponeHeaders(res);
// Figure out whether a JSON or HTTP request has been sent
CmsSpellcheckingRequest cmsSpellcheckingRequest = null;
try {
String requestBody = getRequestBody(servletRequest);
final JSONObject jsonRequest = new JSONObject(requestBody);
cmsSpellcheckingRequest = parseJsonRequest(jsonRequest);
} catch (Exception e) {
LOG.debug(e.getMessage(), e);
cmsSpellcheckingRequest = parseHttpRequest(servletRequest, cms);
}
if ((null != cmsSpellcheckingRequest) && cmsSpellcheckingRequest.isInitialized()) {
// Perform the actual spellchecking
final SpellCheckResponse spellCheckResponse = performSpellcheckQuery(cmsSpellcheckingRequest);
/*
* The field spellCheckResponse is null when exactly one correctly spelled word is passed to the spellchecker.
* In this case it's safe to return an empty JSON formatted map, as the passed word is correct. Otherwise,
* convert the spellchecker response into a new JSON formatted map.
*/
if (null == spellCheckResponse) {
cmsSpellcheckingRequest.m_wordSuggestions = new JSONObject();
} else {
cmsSpellcheckingRequest.m_wordSuggestions = getConvertedResponseAsJson(spellCheckResponse);
}
}
// Send response back to the client
sendResponse(res, cmsSpellcheckingRequest);
} | [
"public",
"void",
"getSpellcheckingResult",
"(",
"final",
"HttpServletResponse",
"res",
",",
"final",
"ServletRequest",
"servletRequest",
",",
"final",
"CmsObject",
"cms",
")",
"throws",
"CmsPermissionViolationException",
",",
"IOException",
"{",
"// Perform a permission ch... | Performs spellchecking using Solr and returns the spellchecking results using JSON.
@param res The HttpServletResponse object.
@param servletRequest The ServletRequest object.
@param cms The CmsObject object.
@throws CmsPermissionViolationException in case of the anonymous guest user
@throws IOException if writing the response fails | [
"Performs",
"spellchecking",
"using",
"Solr",
"and",
"returns",
"the",
"spellchecking",
"results",
"using",
"JSON",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java#L187-L228 | train |
alkacon/opencms-core | src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java | CmsSolrSpellchecker.parseAndAddDictionaries | public void parseAndAddDictionaries(CmsObject cms) throws CmsRoleViolationException {
OpenCms.getRoleManager().checkRole(cms, CmsRole.ROOT_ADMIN);
CmsSpellcheckDictionaryIndexer.parseAndAddZippedDictionaries(m_solrClient, cms);
CmsSpellcheckDictionaryIndexer.parseAndAddDictionaries(m_solrClient, cms);
} | java | public void parseAndAddDictionaries(CmsObject cms) throws CmsRoleViolationException {
OpenCms.getRoleManager().checkRole(cms, CmsRole.ROOT_ADMIN);
CmsSpellcheckDictionaryIndexer.parseAndAddZippedDictionaries(m_solrClient, cms);
CmsSpellcheckDictionaryIndexer.parseAndAddDictionaries(m_solrClient, cms);
} | [
"public",
"void",
"parseAndAddDictionaries",
"(",
"CmsObject",
"cms",
")",
"throws",
"CmsRoleViolationException",
"{",
"OpenCms",
".",
"getRoleManager",
"(",
")",
".",
"checkRole",
"(",
"cms",
",",
"CmsRole",
".",
"ROOT_ADMIN",
")",
";",
"CmsSpellcheckDictionaryInde... | Parses and adds dictionaries to the Solr index.
@param cms the OpenCms object.
@throws CmsRoleViolationException in case the user does not have the required role ROOT_ADMIN | [
"Parses",
"and",
"adds",
"dictionaries",
"to",
"the",
"Solr",
"index",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java#L237-L242 | train |
alkacon/opencms-core | src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java | CmsSolrSpellchecker.getConvertedResponseAsJson | private JSONObject getConvertedResponseAsJson(SpellCheckResponse response) {
if (null == response) {
return null;
}
final JSONObject suggestions = new JSONObject();
final Map<String, Suggestion> solrSuggestions = response.getSuggestionMap();
// Add suggestions to the response
for (final String key : solrSuggestions.keySet()) {
// Indicator to ignore words that are erroneously marked as misspelled.
boolean ignoreWord = false;
// Suggestions that are in the form "Xxxx" -> "xxxx" should be ignored.
if (Character.isUpperCase(key.codePointAt(0))) {
final String lowercaseKey = key.toLowerCase();
// If the suggestion map doesn't contain the lowercased word, ignore this entry.
if (!solrSuggestions.containsKey(lowercaseKey)) {
ignoreWord = true;
}
}
if (!ignoreWord) {
try {
// Get suggestions as List
final List<String> l = solrSuggestions.get(key).getAlternatives();
suggestions.put(key, l);
} catch (JSONException e) {
LOG.debug("Exception while converting Solr spellcheckresponse to JSON. ", e);
}
}
}
return suggestions;
} | java | private JSONObject getConvertedResponseAsJson(SpellCheckResponse response) {
if (null == response) {
return null;
}
final JSONObject suggestions = new JSONObject();
final Map<String, Suggestion> solrSuggestions = response.getSuggestionMap();
// Add suggestions to the response
for (final String key : solrSuggestions.keySet()) {
// Indicator to ignore words that are erroneously marked as misspelled.
boolean ignoreWord = false;
// Suggestions that are in the form "Xxxx" -> "xxxx" should be ignored.
if (Character.isUpperCase(key.codePointAt(0))) {
final String lowercaseKey = key.toLowerCase();
// If the suggestion map doesn't contain the lowercased word, ignore this entry.
if (!solrSuggestions.containsKey(lowercaseKey)) {
ignoreWord = true;
}
}
if (!ignoreWord) {
try {
// Get suggestions as List
final List<String> l = solrSuggestions.get(key).getAlternatives();
suggestions.put(key, l);
} catch (JSONException e) {
LOG.debug("Exception while converting Solr spellcheckresponse to JSON. ", e);
}
}
}
return suggestions;
} | [
"private",
"JSONObject",
"getConvertedResponseAsJson",
"(",
"SpellCheckResponse",
"response",
")",
"{",
"if",
"(",
"null",
"==",
"response",
")",
"{",
"return",
"null",
";",
"}",
"final",
"JSONObject",
"suggestions",
"=",
"new",
"JSONObject",
"(",
")",
";",
"f... | Converts the suggestions from the Solrj format to JSON format.
@param response The SpellCheckResponse object containing the spellcheck results.
@return The spellcheck suggestions as JSON object or null if something goes wrong. | [
"Converts",
"the",
"suggestions",
"from",
"the",
"Solrj",
"format",
"to",
"JSON",
"format",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java#L250-L286 | train |
alkacon/opencms-core | src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java | CmsSolrSpellchecker.getJsonFormattedSpellcheckResult | private JSONObject getJsonFormattedSpellcheckResult(CmsSpellcheckingRequest request) {
final JSONObject response = new JSONObject();
try {
if (null != request.m_id) {
response.put(JSON_ID, request.m_id);
}
response.put(JSON_RESULT, request.m_wordSuggestions);
} catch (Exception e) {
try {
response.put(JSON_ERROR, true);
LOG.debug("Error while assembling spellcheck response in JSON format.", e);
} catch (JSONException ex) {
LOG.debug("Error while assembling spellcheck response in JSON format.", ex);
}
}
return response;
} | java | private JSONObject getJsonFormattedSpellcheckResult(CmsSpellcheckingRequest request) {
final JSONObject response = new JSONObject();
try {
if (null != request.m_id) {
response.put(JSON_ID, request.m_id);
}
response.put(JSON_RESULT, request.m_wordSuggestions);
} catch (Exception e) {
try {
response.put(JSON_ERROR, true);
LOG.debug("Error while assembling spellcheck response in JSON format.", e);
} catch (JSONException ex) {
LOG.debug("Error while assembling spellcheck response in JSON format.", ex);
}
}
return response;
} | [
"private",
"JSONObject",
"getJsonFormattedSpellcheckResult",
"(",
"CmsSpellcheckingRequest",
"request",
")",
"{",
"final",
"JSONObject",
"response",
"=",
"new",
"JSONObject",
"(",
")",
";",
"try",
"{",
"if",
"(",
"null",
"!=",
"request",
".",
"m_id",
")",
"{",
... | Returns the result of the performed spellcheck formatted in JSON.
@param request The CmsSpellcheckingRequest.
@return JSONObject that contains the result of the performed spellcheck. | [
"Returns",
"the",
"result",
"of",
"the",
"performed",
"spellcheck",
"formatted",
"in",
"JSON",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java#L294-L315 | train |
alkacon/opencms-core | src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java | CmsSolrSpellchecker.getRequestBody | private String getRequestBody(ServletRequest request) throws IOException {
final StringBuilder sb = new StringBuilder();
String line = request.getReader().readLine();
while (null != line) {
sb.append(line);
line = request.getReader().readLine();
}
return sb.toString();
} | java | private String getRequestBody(ServletRequest request) throws IOException {
final StringBuilder sb = new StringBuilder();
String line = request.getReader().readLine();
while (null != line) {
sb.append(line);
line = request.getReader().readLine();
}
return sb.toString();
} | [
"private",
"String",
"getRequestBody",
"(",
"ServletRequest",
"request",
")",
"throws",
"IOException",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"line",
"=",
"request",
".",
"getReader",
"(",
")",
".",
"readLine... | Returns the body of the request. This method is used to read posted JSON data.
@param request The request.
@return String representation of the request's body.
@throws IOException in case reading the request fails | [
"Returns",
"the",
"body",
"of",
"the",
"request",
".",
"This",
"method",
"is",
"used",
"to",
"read",
"posted",
"JSON",
"data",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java#L326-L337 | train |
alkacon/opencms-core | src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java | CmsSolrSpellchecker.parseHttpRequest | private CmsSpellcheckingRequest parseHttpRequest(final ServletRequest req, final CmsObject cms) {
if ((null != cms) && OpenCms.getRoleManager().hasRole(cms, CmsRole.ROOT_ADMIN)) {
try {
if (null != req.getParameter(HTTP_PARAMETER_CHECKREBUILD)) {
if (CmsSpellcheckDictionaryIndexer.updatingIndexNecessesary(cms)) {
parseAndAddDictionaries(cms);
}
}
if (null != req.getParameter(HTTP_PARAMTER_REBUILD)) {
parseAndAddDictionaries(cms);
}
} catch (CmsRoleViolationException e) {
LOG.error(e.getLocalizedMessage(), e);
}
}
final String q = req.getParameter(HTTP_PARAMETER_WORDS);
if (null == q) {
LOG.debug("Invalid HTTP request: No parameter \"" + HTTP_PARAMETER_WORDS + "\" defined. ");
return null;
}
final StringTokenizer st = new StringTokenizer(q);
final List<String> wordsToCheck = new ArrayList<String>();
while (st.hasMoreTokens()) {
final String word = st.nextToken();
wordsToCheck.add(word);
if (Character.isUpperCase(word.codePointAt(0))) {
wordsToCheck.add(word.toLowerCase());
}
}
final String[] w = wordsToCheck.toArray(new String[wordsToCheck.size()]);
final String dict = req.getParameter(HTTP_PARAMETER_LANG) == null
? LANG_DEFAULT
: req.getParameter(HTTP_PARAMETER_LANG);
return new CmsSpellcheckingRequest(w, dict);
} | java | private CmsSpellcheckingRequest parseHttpRequest(final ServletRequest req, final CmsObject cms) {
if ((null != cms) && OpenCms.getRoleManager().hasRole(cms, CmsRole.ROOT_ADMIN)) {
try {
if (null != req.getParameter(HTTP_PARAMETER_CHECKREBUILD)) {
if (CmsSpellcheckDictionaryIndexer.updatingIndexNecessesary(cms)) {
parseAndAddDictionaries(cms);
}
}
if (null != req.getParameter(HTTP_PARAMTER_REBUILD)) {
parseAndAddDictionaries(cms);
}
} catch (CmsRoleViolationException e) {
LOG.error(e.getLocalizedMessage(), e);
}
}
final String q = req.getParameter(HTTP_PARAMETER_WORDS);
if (null == q) {
LOG.debug("Invalid HTTP request: No parameter \"" + HTTP_PARAMETER_WORDS + "\" defined. ");
return null;
}
final StringTokenizer st = new StringTokenizer(q);
final List<String> wordsToCheck = new ArrayList<String>();
while (st.hasMoreTokens()) {
final String word = st.nextToken();
wordsToCheck.add(word);
if (Character.isUpperCase(word.codePointAt(0))) {
wordsToCheck.add(word.toLowerCase());
}
}
final String[] w = wordsToCheck.toArray(new String[wordsToCheck.size()]);
final String dict = req.getParameter(HTTP_PARAMETER_LANG) == null
? LANG_DEFAULT
: req.getParameter(HTTP_PARAMETER_LANG);
return new CmsSpellcheckingRequest(w, dict);
} | [
"private",
"CmsSpellcheckingRequest",
"parseHttpRequest",
"(",
"final",
"ServletRequest",
"req",
",",
"final",
"CmsObject",
"cms",
")",
"{",
"if",
"(",
"(",
"null",
"!=",
"cms",
")",
"&&",
"OpenCms",
".",
"getRoleManager",
"(",
")",
".",
"hasRole",
"(",
"cms... | Parse parameters from this request using HTTP.
@param req The ServletRequest containing all request parameters.
@param cms The OpenCms object.
@return CmsSpellcheckingRequest object that contains parsed parameters. | [
"Parse",
"parameters",
"from",
"this",
"request",
"using",
"HTTP",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java#L346-L390 | train |
alkacon/opencms-core | src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java | CmsSolrSpellchecker.parseJsonRequest | private CmsSpellcheckingRequest parseJsonRequest(JSONObject jsonRequest) {
final String id = jsonRequest.optString(JSON_ID);
final JSONObject params = jsonRequest.optJSONObject(JSON_PARAMS);
if (null == params) {
LOG.debug("Invalid JSON request: No field \"params\" defined. ");
return null;
}
final JSONArray words = params.optJSONArray(JSON_WORDS);
final String lang = params.optString(JSON_LANG, LANG_DEFAULT);
if (null == words) {
LOG.debug("Invalid JSON request: No field \"words\" defined. ");
return null;
}
// Convert JSON array to array of type String
final List<String> wordsToCheck = new LinkedList<String>();
for (int i = 0; i < words.length(); i++) {
final String word = words.opt(i).toString();
wordsToCheck.add(word);
if (Character.isUpperCase(word.codePointAt(0))) {
wordsToCheck.add(word.toLowerCase());
}
}
return new CmsSpellcheckingRequest(wordsToCheck.toArray(new String[wordsToCheck.size()]), lang, id);
} | java | private CmsSpellcheckingRequest parseJsonRequest(JSONObject jsonRequest) {
final String id = jsonRequest.optString(JSON_ID);
final JSONObject params = jsonRequest.optJSONObject(JSON_PARAMS);
if (null == params) {
LOG.debug("Invalid JSON request: No field \"params\" defined. ");
return null;
}
final JSONArray words = params.optJSONArray(JSON_WORDS);
final String lang = params.optString(JSON_LANG, LANG_DEFAULT);
if (null == words) {
LOG.debug("Invalid JSON request: No field \"words\" defined. ");
return null;
}
// Convert JSON array to array of type String
final List<String> wordsToCheck = new LinkedList<String>();
for (int i = 0; i < words.length(); i++) {
final String word = words.opt(i).toString();
wordsToCheck.add(word);
if (Character.isUpperCase(word.codePointAt(0))) {
wordsToCheck.add(word.toLowerCase());
}
}
return new CmsSpellcheckingRequest(wordsToCheck.toArray(new String[wordsToCheck.size()]), lang, id);
} | [
"private",
"CmsSpellcheckingRequest",
"parseJsonRequest",
"(",
"JSONObject",
"jsonRequest",
")",
"{",
"final",
"String",
"id",
"=",
"jsonRequest",
".",
"optString",
"(",
"JSON_ID",
")",
";",
"final",
"JSONObject",
"params",
"=",
"jsonRequest",
".",
"optJSONObject",
... | Parse JSON parameters from this request.
@param jsonRequest The request in the JSON format.
@return CmsSpellcheckingRequest object that contains parsed parameters or null, if JSON input is not well
defined. | [
"Parse",
"JSON",
"parameters",
"from",
"this",
"request",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java#L399-L428 | train |
alkacon/opencms-core | src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java | CmsSolrSpellchecker.performPermissionCheck | private void performPermissionCheck(CmsObject cms) throws CmsPermissionViolationException {
if (cms.getRequestContext().getCurrentUser().isGuestUser()) {
throw new CmsPermissionViolationException(null);
}
} | java | private void performPermissionCheck(CmsObject cms) throws CmsPermissionViolationException {
if (cms.getRequestContext().getCurrentUser().isGuestUser()) {
throw new CmsPermissionViolationException(null);
}
} | [
"private",
"void",
"performPermissionCheck",
"(",
"CmsObject",
"cms",
")",
"throws",
"CmsPermissionViolationException",
"{",
"if",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
".",
"isGuestUser",
"(",
")",
")",
"{",
"throw",
... | Perform a security check against OpenCms.
@param cms The OpenCms object.
@throws CmsPermissionViolationException in case of the anonymous guest user | [
"Perform",
"a",
"security",
"check",
"against",
"OpenCms",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java#L437-L442 | train |
alkacon/opencms-core | src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java | CmsSolrSpellchecker.performSpellcheckQuery | private SpellCheckResponse performSpellcheckQuery(CmsSpellcheckingRequest request) {
if ((null == request) || !request.isInitialized()) {
return null;
}
final String[] wordsToCheck = request.m_wordsToCheck;
final ModifiableSolrParams params = new ModifiableSolrParams();
params.set("spellcheck", "true");
params.set("spellcheck.dictionary", request.m_dictionaryToUse);
params.set("spellcheck.extendedResults", "true");
// Build one string from array of words and use it as query.
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < wordsToCheck.length; i++) {
builder.append(wordsToCheck[i] + " ");
}
params.set("spellcheck.q", builder.toString());
final SolrQuery query = new SolrQuery();
query.setRequestHandler("/spell");
query.add(params);
try {
QueryResponse qres = m_solrClient.query(query);
return qres.getSpellCheckResponse();
} catch (Exception e) {
LOG.debug("Exception while performing spellcheck query...", e);
}
return null;
} | java | private SpellCheckResponse performSpellcheckQuery(CmsSpellcheckingRequest request) {
if ((null == request) || !request.isInitialized()) {
return null;
}
final String[] wordsToCheck = request.m_wordsToCheck;
final ModifiableSolrParams params = new ModifiableSolrParams();
params.set("spellcheck", "true");
params.set("spellcheck.dictionary", request.m_dictionaryToUse);
params.set("spellcheck.extendedResults", "true");
// Build one string from array of words and use it as query.
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < wordsToCheck.length; i++) {
builder.append(wordsToCheck[i] + " ");
}
params.set("spellcheck.q", builder.toString());
final SolrQuery query = new SolrQuery();
query.setRequestHandler("/spell");
query.add(params);
try {
QueryResponse qres = m_solrClient.query(query);
return qres.getSpellCheckResponse();
} catch (Exception e) {
LOG.debug("Exception while performing spellcheck query...", e);
}
return null;
} | [
"private",
"SpellCheckResponse",
"performSpellcheckQuery",
"(",
"CmsSpellcheckingRequest",
"request",
")",
"{",
"if",
"(",
"(",
"null",
"==",
"request",
")",
"||",
"!",
"request",
".",
"isInitialized",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"final",
... | Performs the actual spell check query using Solr.
@param request the spell check request
@return Results of the Solr spell check of type SpellCheckResponse or null if something goes wrong. | [
"Performs",
"the",
"actual",
"spell",
"check",
"query",
"using",
"Solr",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java#L451-L484 | train |
alkacon/opencms-core | src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java | CmsSolrSpellchecker.sendResponse | private void sendResponse(final HttpServletResponse res, final CmsSpellcheckingRequest request) throws IOException {
final PrintWriter pw = res.getWriter();
final JSONObject response = getJsonFormattedSpellcheckResult(request);
pw.println(response.toString());
pw.close();
} | java | private void sendResponse(final HttpServletResponse res, final CmsSpellcheckingRequest request) throws IOException {
final PrintWriter pw = res.getWriter();
final JSONObject response = getJsonFormattedSpellcheckResult(request);
pw.println(response.toString());
pw.close();
} | [
"private",
"void",
"sendResponse",
"(",
"final",
"HttpServletResponse",
"res",
",",
"final",
"CmsSpellcheckingRequest",
"request",
")",
"throws",
"IOException",
"{",
"final",
"PrintWriter",
"pw",
"=",
"res",
".",
"getWriter",
"(",
")",
";",
"final",
"JSONObject",
... | Sends the JSON-formatted spellchecking results to the client.
@param res The HttpServletResponse object.
@param request The spellchecking request object.
@throws IOException in case writing the response fails | [
"Sends",
"the",
"JSON",
"-",
"formatted",
"spellchecking",
"results",
"to",
"the",
"client",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java#L494-L500 | train |
alkacon/opencms-core | src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java | CmsSolrSpellchecker.setResponeHeaders | private void setResponeHeaders(HttpServletResponse response) {
response.setHeader("Cache-Control", "no-store, no-cache");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", System.currentTimeMillis());
response.setContentType("text/plain; charset=utf-8");
response.setCharacterEncoding("utf-8");
} | java | private void setResponeHeaders(HttpServletResponse response) {
response.setHeader("Cache-Control", "no-store, no-cache");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", System.currentTimeMillis());
response.setContentType("text/plain; charset=utf-8");
response.setCharacterEncoding("utf-8");
} | [
"private",
"void",
"setResponeHeaders",
"(",
"HttpServletResponse",
"response",
")",
"{",
"response",
".",
"setHeader",
"(",
"\"Cache-Control\"",
",",
"\"no-store, no-cache\"",
")",
";",
"response",
".",
"setHeader",
"(",
"\"Pragma\"",
",",
"\"no-cache\"",
")",
";",... | Sets the appropriate headers to response of this request.
@param response The HttpServletResponse response object. | [
"Sets",
"the",
"appropriate",
"headers",
"to",
"response",
"of",
"this",
"request",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java#L507-L514 | train |
alkacon/opencms-core | src/org/opencms/acacia/shared/CmsSerialDateUtil.java | CmsSerialDateUtil.toIntWithDefault | public static int toIntWithDefault(String value, int defaultValue) {
int result = defaultValue;
try {
result = Integer.parseInt(value);
} catch (@SuppressWarnings("unused") Exception e) {
// Do nothing, return default.
}
return result;
} | java | public static int toIntWithDefault(String value, int defaultValue) {
int result = defaultValue;
try {
result = Integer.parseInt(value);
} catch (@SuppressWarnings("unused") Exception e) {
// Do nothing, return default.
}
return result;
} | [
"public",
"static",
"int",
"toIntWithDefault",
"(",
"String",
"value",
",",
"int",
"defaultValue",
")",
"{",
"int",
"result",
"=",
"defaultValue",
";",
"try",
"{",
"result",
"=",
"Integer",
".",
"parseInt",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"@",... | Parses int value and returns the provided default if the value can't be parsed.
@param value the int to parse.
@param defaultValue the default value.
@return the parsed int, or the default value if parsing fails. | [
"Parses",
"int",
"value",
"and",
"returns",
"the",
"provided",
"default",
"if",
"the",
"value",
"can",
"t",
"be",
"parsed",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/acacia/shared/CmsSerialDateUtil.java#L48-L57 | train |
alkacon/opencms-core | src/org/opencms/search/solr/updateprocessors/CmsSolrCopyModifiedUpateProcessorFactory.java | CmsSolrCopyModifiedUpateProcessorFactory.init | @Override
public void init(NamedList args) {
Object regex = args.remove(PARAM_REGEX);
if (null == regex) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_REGEX);
}
try {
m_regex = Pattern.compile(regex.toString());
} catch (PatternSyntaxException e) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Invalid regex: " + regex, e);
}
Object replacement = args.remove(PARAM_REPLACEMENT);
if (null == replacement) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_REPLACEMENT);
}
m_replacement = replacement.toString();
Object source = args.remove(PARAM_SOURCE);
if (null == source) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_SOURCE);
}
m_source = source.toString();
Object target = args.remove(PARAM_TARGET);
if (null == target) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_TARGET);
}
m_target = target.toString();
} | java | @Override
public void init(NamedList args) {
Object regex = args.remove(PARAM_REGEX);
if (null == regex) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_REGEX);
}
try {
m_regex = Pattern.compile(regex.toString());
} catch (PatternSyntaxException e) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Invalid regex: " + regex, e);
}
Object replacement = args.remove(PARAM_REPLACEMENT);
if (null == replacement) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_REPLACEMENT);
}
m_replacement = replacement.toString();
Object source = args.remove(PARAM_SOURCE);
if (null == source) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_SOURCE);
}
m_source = source.toString();
Object target = args.remove(PARAM_TARGET);
if (null == target) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_TARGET);
}
m_target = target.toString();
} | [
"@",
"Override",
"public",
"void",
"init",
"(",
"NamedList",
"args",
")",
"{",
"Object",
"regex",
"=",
"args",
".",
"remove",
"(",
"PARAM_REGEX",
")",
";",
"if",
"(",
"null",
"==",
"regex",
")",
"{",
"throw",
"new",
"SolrException",
"(",
"ErrorCode",
"... | Read the parameters on initialization.
@see org.apache.solr.update.processor.UpdateRequestProcessorFactory#init(org.apache.solr.common.util.NamedList) | [
"Read",
"the",
"parameters",
"on",
"initialization",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/updateprocessors/CmsSolrCopyModifiedUpateProcessorFactory.java#L124-L155 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsSimpleSearchConfigurationParser.java | CmsSimpleSearchConfigurationParser.getDefaultReturnFields | String getDefaultReturnFields() {
StringBuffer fields = new StringBuffer("");
fields.append(CmsSearchField.FIELD_PATH);
fields.append(',');
fields.append(CmsSearchField.FIELD_INSTANCEDATE).append('_').append(getSearchLocale().toString()).append("_dt");
fields.append(',');
fields.append(CmsSearchField.FIELD_INSTANCEDATE_END).append('_').append(getSearchLocale().toString()).append(
"_dt");
fields.append(',');
fields.append(CmsSearchField.FIELD_INSTANCEDATE_CURRENT_TILL).append('_').append(
getSearchLocale().toString()).append("_dt");
fields.append(',');
fields.append(CmsSearchField.FIELD_ID);
fields.append(',');
fields.append(CmsSearchField.FIELD_SOLR_ID);
fields.append(',');
fields.append(CmsSearchField.FIELD_DISPTITLE).append('_').append(getSearchLocale().toString()).append("_sort");
fields.append(',');
fields.append(CmsSearchField.FIELD_LINK);
return fields.toString();
} | java | String getDefaultReturnFields() {
StringBuffer fields = new StringBuffer("");
fields.append(CmsSearchField.FIELD_PATH);
fields.append(',');
fields.append(CmsSearchField.FIELD_INSTANCEDATE).append('_').append(getSearchLocale().toString()).append("_dt");
fields.append(',');
fields.append(CmsSearchField.FIELD_INSTANCEDATE_END).append('_').append(getSearchLocale().toString()).append(
"_dt");
fields.append(',');
fields.append(CmsSearchField.FIELD_INSTANCEDATE_CURRENT_TILL).append('_').append(
getSearchLocale().toString()).append("_dt");
fields.append(',');
fields.append(CmsSearchField.FIELD_ID);
fields.append(',');
fields.append(CmsSearchField.FIELD_SOLR_ID);
fields.append(',');
fields.append(CmsSearchField.FIELD_DISPTITLE).append('_').append(getSearchLocale().toString()).append("_sort");
fields.append(',');
fields.append(CmsSearchField.FIELD_LINK);
return fields.toString();
} | [
"String",
"getDefaultReturnFields",
"(",
")",
"{",
"StringBuffer",
"fields",
"=",
"new",
"StringBuffer",
"(",
"\"\"",
")",
";",
"fields",
".",
"append",
"(",
"CmsSearchField",
".",
"FIELD_PATH",
")",
";",
"fields",
".",
"append",
"(",
"'",
"'",
")",
";",
... | The fields returned by default. Typically the output is done via display formatters and hence nearly no
field is necessary. Returning all fields might cause performance problems.
@return the default return fields. | [
"The",
"fields",
"returned",
"by",
"default",
".",
"Typically",
"the",
"output",
"is",
"done",
"via",
"display",
"formatters",
"and",
"hence",
"nearly",
"no",
"field",
"is",
"necessary",
".",
"Returning",
"all",
"fields",
"might",
"cause",
"performance",
"prob... | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsSimpleSearchConfigurationParser.java#L534-L555 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsSimpleSearchConfigurationParser.java | CmsSimpleSearchConfigurationParser.getDefaultFieldFacets | private Map<String, I_CmsSearchConfigurationFacetField> getDefaultFieldFacets(boolean categoryConjunction) {
Map<String, I_CmsSearchConfigurationFacetField> fieldFacets = new HashMap<String, I_CmsSearchConfigurationFacetField>();
fieldFacets.put(
CmsListManager.FIELD_CATEGORIES,
new CmsSearchConfigurationFacetField(
CmsListManager.FIELD_CATEGORIES,
null,
Integer.valueOf(1),
Integer.valueOf(200),
null,
"Category",
SortOrder.index,
null,
Boolean.valueOf(categoryConjunction),
null,
Boolean.TRUE));
fieldFacets.put(
CmsListManager.FIELD_PARENT_FOLDERS,
new CmsSearchConfigurationFacetField(
CmsListManager.FIELD_PARENT_FOLDERS,
null,
Integer.valueOf(1),
Integer.valueOf(200),
null,
"Folders",
SortOrder.index,
null,
Boolean.FALSE,
null,
Boolean.TRUE));
return Collections.unmodifiableMap(fieldFacets);
} | java | private Map<String, I_CmsSearchConfigurationFacetField> getDefaultFieldFacets(boolean categoryConjunction) {
Map<String, I_CmsSearchConfigurationFacetField> fieldFacets = new HashMap<String, I_CmsSearchConfigurationFacetField>();
fieldFacets.put(
CmsListManager.FIELD_CATEGORIES,
new CmsSearchConfigurationFacetField(
CmsListManager.FIELD_CATEGORIES,
null,
Integer.valueOf(1),
Integer.valueOf(200),
null,
"Category",
SortOrder.index,
null,
Boolean.valueOf(categoryConjunction),
null,
Boolean.TRUE));
fieldFacets.put(
CmsListManager.FIELD_PARENT_FOLDERS,
new CmsSearchConfigurationFacetField(
CmsListManager.FIELD_PARENT_FOLDERS,
null,
Integer.valueOf(1),
Integer.valueOf(200),
null,
"Folders",
SortOrder.index,
null,
Boolean.FALSE,
null,
Boolean.TRUE));
return Collections.unmodifiableMap(fieldFacets);
} | [
"private",
"Map",
"<",
"String",
",",
"I_CmsSearchConfigurationFacetField",
">",
"getDefaultFieldFacets",
"(",
"boolean",
"categoryConjunction",
")",
"{",
"Map",
"<",
"String",
",",
"I_CmsSearchConfigurationFacetField",
">",
"fieldFacets",
"=",
"new",
"HashMap",
"<",
... | The default field facets.
@param categoryConjunction flag, indicating if category selections in the facet should be "AND" combined.
@return the default field facets. | [
"The",
"default",
"field",
"facets",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsSimpleSearchConfigurationParser.java#L637-L670 | train |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/util/CmsDomUtil.java | CmsDomUtil.stripHtml | public static String stripHtml(String html) {
if (html == null) {
return null;
}
Element el = DOM.createDiv();
el.setInnerHTML(html);
return el.getInnerText();
} | java | public static String stripHtml(String html) {
if (html == null) {
return null;
}
Element el = DOM.createDiv();
el.setInnerHTML(html);
return el.getInnerText();
} | [
"public",
"static",
"String",
"stripHtml",
"(",
"String",
"html",
")",
"{",
"if",
"(",
"html",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Element",
"el",
"=",
"DOM",
".",
"createDiv",
"(",
")",
";",
"el",
".",
"setInnerHTML",
"(",
"html",
... | Returns the text content to any HTML.
@param html the HTML
@return the text content | [
"Returns",
"the",
"text",
"content",
"to",
"any",
"HTML",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/util/CmsDomUtil.java#L2081-L2089 | train |
alkacon/opencms-core | src/org/opencms/main/CmsShellCommands.java | CmsShellCommands.setUserInfo | public void setUserInfo(String username, String infoName, String value) throws CmsException {
CmsUser user = m_cms.readUser(username);
user.setAdditionalInfo(infoName, value);
m_cms.writeUser(user);
} | java | public void setUserInfo(String username, String infoName, String value) throws CmsException {
CmsUser user = m_cms.readUser(username);
user.setAdditionalInfo(infoName, value);
m_cms.writeUser(user);
} | [
"public",
"void",
"setUserInfo",
"(",
"String",
"username",
",",
"String",
"infoName",
",",
"String",
"value",
")",
"throws",
"CmsException",
"{",
"CmsUser",
"user",
"=",
"m_cms",
".",
"readUser",
"(",
"username",
")",
";",
"user",
".",
"setAdditionalInfo",
... | Sets a string-valued additional info entry on the user.
@param username the name of the user
@param infoName the additional info key
@param value the additional info value
@throws CmsException if something goes wrong | [
"Sets",
"a",
"string",
"-",
"valued",
"additional",
"info",
"entry",
"on",
"the",
"user",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/main/CmsShellCommands.java#L1589-L1594 | train |
alkacon/opencms-core | src-modules/org/opencms/workplace/commons/CmsPreferences.java | CmsPreferences.setTimewarpInt | public void setTimewarpInt(String timewarp) {
try {
m_userSettings.setTimeWarp(Long.valueOf(timewarp).longValue());
} catch (Exception e) {
m_userSettings.setTimeWarp(-1);
}
} | java | public void setTimewarpInt(String timewarp) {
try {
m_userSettings.setTimeWarp(Long.valueOf(timewarp).longValue());
} catch (Exception e) {
m_userSettings.setTimeWarp(-1);
}
} | [
"public",
"void",
"setTimewarpInt",
"(",
"String",
"timewarp",
")",
"{",
"try",
"{",
"m_userSettings",
".",
"setTimeWarp",
"(",
"Long",
".",
"valueOf",
"(",
"timewarp",
")",
".",
"longValue",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
... | Sets the timewarp setting from a numeric string
@param timewarp a numeric string containing the number of milliseconds since the epoch | [
"Sets",
"the",
"timewarp",
"setting",
"from",
"a",
"numeric",
"string"
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/commons/CmsPreferences.java#L2131-L2138 | train |
alkacon/opencms-core | src-modules/org/opencms/workplace/commons/CmsPreferences.java | CmsPreferences.buildSelect | String buildSelect(String htmlAttributes, SelectOptions options) {
return buildSelect(htmlAttributes, options.getOptions(), options.getValues(), options.getSelectedIndex());
} | java | String buildSelect(String htmlAttributes, SelectOptions options) {
return buildSelect(htmlAttributes, options.getOptions(), options.getValues(), options.getSelectedIndex());
} | [
"String",
"buildSelect",
"(",
"String",
"htmlAttributes",
",",
"SelectOptions",
"options",
")",
"{",
"return",
"buildSelect",
"(",
"htmlAttributes",
",",
"options",
".",
"getOptions",
"(",
")",
",",
"options",
".",
"getValues",
"(",
")",
",",
"options",
".",
... | Builds the HTML code for a select widget given a bean containing the select options
@param htmlAttributes html attributes for the select widget
@param options the bean containing the select options
@return the HTML for the select box | [
"Builds",
"the",
"HTML",
"code",
"for",
"a",
"select",
"widget",
"given",
"a",
"bean",
"containing",
"the",
"select",
"options"
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/commons/CmsPreferences.java#L2257-L2260 | train |
alkacon/opencms-core | src/org/opencms/ui/apps/git/CmsGitConfiguration.java | CmsGitConfiguration.getValueFromProp | private String getValueFromProp(final String propValue) {
String value = propValue;
// remove quotes
value = value.trim();
if ((value.startsWith("\"") && value.endsWith("\"")) || (value.startsWith("'") && value.endsWith("'"))) {
value = value.substring(1, value.length() - 1);
}
return value;
} | java | private String getValueFromProp(final String propValue) {
String value = propValue;
// remove quotes
value = value.trim();
if ((value.startsWith("\"") && value.endsWith("\"")) || (value.startsWith("'") && value.endsWith("'"))) {
value = value.substring(1, value.length() - 1);
}
return value;
} | [
"private",
"String",
"getValueFromProp",
"(",
"final",
"String",
"propValue",
")",
"{",
"String",
"value",
"=",
"propValue",
";",
"// remove quotes",
"value",
"=",
"value",
".",
"trim",
"(",
")",
";",
"if",
"(",
"(",
"value",
".",
"startsWith",
"(",
"\"\\\... | Helper to read a line from the config file.
@param propValue the property value
@return the value of the variable set at this line. | [
"Helper",
"to",
"read",
"a",
"line",
"from",
"the",
"config",
"file",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/git/CmsGitConfiguration.java#L304-L313 | train |
alkacon/opencms-core | src/org/opencms/xml/containerpage/CmsADESessionCache.java | CmsADESessionCache.getDynamicValue | public String getDynamicValue(String attribute) {
return null == m_dynamicValues ? null : m_dynamicValues.get(attribute);
} | java | public String getDynamicValue(String attribute) {
return null == m_dynamicValues ? null : m_dynamicValues.get(attribute);
} | [
"public",
"String",
"getDynamicValue",
"(",
"String",
"attribute",
")",
"{",
"return",
"null",
"==",
"m_dynamicValues",
"?",
"null",
":",
"m_dynamicValues",
".",
"get",
"(",
"attribute",
")",
";",
"}"
] | Get cached value that is dynamically loaded by the Acacia content editor.
@param attribute the attribute to load the value to
@return the cached value | [
"Get",
"cached",
"value",
"that",
"is",
"dynamically",
"loaded",
"by",
"the",
"Acacia",
"content",
"editor",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/containerpage/CmsADESessionCache.java#L289-L292 | train |
alkacon/opencms-core | src/org/opencms/xml/containerpage/CmsADESessionCache.java | CmsADESessionCache.setDynamicValue | public void setDynamicValue(String attribute, String value) {
if (null == m_dynamicValues) {
m_dynamicValues = new ConcurrentHashMap<String, String>();
}
m_dynamicValues.put(attribute, value);
} | java | public void setDynamicValue(String attribute, String value) {
if (null == m_dynamicValues) {
m_dynamicValues = new ConcurrentHashMap<String, String>();
}
m_dynamicValues.put(attribute, value);
} | [
"public",
"void",
"setDynamicValue",
"(",
"String",
"attribute",
",",
"String",
"value",
")",
"{",
"if",
"(",
"null",
"==",
"m_dynamicValues",
")",
"{",
"m_dynamicValues",
"=",
"new",
"ConcurrentHashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"... | Set cached value for the attribute. Used for dynamically loaded values in the Acacia content editor.
@param attribute the attribute for which the value should be cached
@param value the value to cache | [
"Set",
"cached",
"value",
"for",
"the",
"attribute",
".",
"Used",
"for",
"dynamically",
"loaded",
"values",
"in",
"the",
"Acacia",
"content",
"editor",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/containerpage/CmsADESessionCache.java#L429-L435 | train |
alkacon/opencms-core | src/org/opencms/widgets/CmsHtmlWidgetOption.java | CmsHtmlWidgetOption.parseEmbeddedGalleryOptions | public static CmsPair<String, Map<String, String>> parseEmbeddedGalleryOptions(String configuration) {
final Map<String, String> galleryOptions = Maps.newHashMap();
String resultConfig = CmsStringUtil.substitute(
PATTERN_EMBEDDED_GALLERY_CONFIG,
configuration,
new I_CmsRegexSubstitution() {
public String substituteMatch(String string, Matcher matcher) {
String galleryName = string.substring(matcher.start(1), matcher.end(1));
String embeddedConfig = string.substring(matcher.start(2), matcher.end(2));
galleryOptions.put(galleryName, embeddedConfig);
return galleryName;
}
});
return CmsPair.create(resultConfig, galleryOptions);
} | java | public static CmsPair<String, Map<String, String>> parseEmbeddedGalleryOptions(String configuration) {
final Map<String, String> galleryOptions = Maps.newHashMap();
String resultConfig = CmsStringUtil.substitute(
PATTERN_EMBEDDED_GALLERY_CONFIG,
configuration,
new I_CmsRegexSubstitution() {
public String substituteMatch(String string, Matcher matcher) {
String galleryName = string.substring(matcher.start(1), matcher.end(1));
String embeddedConfig = string.substring(matcher.start(2), matcher.end(2));
galleryOptions.put(galleryName, embeddedConfig);
return galleryName;
}
});
return CmsPair.create(resultConfig, galleryOptions);
} | [
"public",
"static",
"CmsPair",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"parseEmbeddedGalleryOptions",
"(",
"String",
"configuration",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"galleryOptions",
"=",
"Maps",
".",
... | Parses and removes embedded gallery configuration strings.
@param configuration the configuration string to parse
@return a map containing both the string resulting from removing the embedded configurations, and the embedded configurations as a a map | [
"Parses",
"and",
"removes",
"embedded",
"gallery",
"configuration",
"strings",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/widgets/CmsHtmlWidgetOption.java#L497-L514 | train |
alkacon/opencms-core | src-gwt/org/opencms/ade/galleries/client/preview/CmsFocalPointController.java | CmsFocalPointController.updateScaling | private void updateScaling() {
List<I_CmsTransform> transforms = new ArrayList<>();
CmsCroppingParamBean crop = m_croppingProvider.get();
CmsImageInfoBean info = m_imageInfoProvider.get();
double wv = m_image.getElement().getParentElement().getOffsetWidth();
double hv = m_image.getElement().getParentElement().getOffsetHeight();
if (crop == null) {
transforms.add(
new CmsBoxFit(CmsBoxFit.Mode.scaleOnlyIfNecessary, wv, hv, info.getWidth(), info.getHeight()));
} else {
int wt, ht;
wt = crop.getTargetWidth() >= 0 ? crop.getTargetWidth() : info.getWidth();
ht = crop.getTargetHeight() >= 0 ? crop.getTargetHeight() : info.getHeight();
transforms.add(new CmsBoxFit(CmsBoxFit.Mode.scaleOnlyIfNecessary, wv, hv, wt, ht));
if (crop.isCropped()) {
transforms.add(
new CmsBoxFit(CmsBoxFit.Mode.scaleAlways, wt, ht, crop.getCropWidth(), crop.getCropHeight()));
transforms.add(new CmsTranslate(crop.getCropX(), crop.getCropY()));
} else {
transforms.add(
new CmsBoxFit(CmsBoxFit.Mode.scaleAlways, wt, ht, crop.getOrgWidth(), crop.getOrgHeight()));
}
}
CmsCompositeTransform chain = new CmsCompositeTransform(transforms);
m_coordinateTransform = chain;
if ((crop == null) || !crop.isCropped()) {
m_region = transformRegionBack(
m_coordinateTransform,
CmsRectangle.fromLeftTopWidthHeight(0, 0, info.getWidth(), info.getHeight()));
} else {
m_region = transformRegionBack(
m_coordinateTransform,
CmsRectangle.fromLeftTopWidthHeight(
crop.getCropX(),
crop.getCropY(),
crop.getCropWidth(),
crop.getCropHeight()));
}
} | java | private void updateScaling() {
List<I_CmsTransform> transforms = new ArrayList<>();
CmsCroppingParamBean crop = m_croppingProvider.get();
CmsImageInfoBean info = m_imageInfoProvider.get();
double wv = m_image.getElement().getParentElement().getOffsetWidth();
double hv = m_image.getElement().getParentElement().getOffsetHeight();
if (crop == null) {
transforms.add(
new CmsBoxFit(CmsBoxFit.Mode.scaleOnlyIfNecessary, wv, hv, info.getWidth(), info.getHeight()));
} else {
int wt, ht;
wt = crop.getTargetWidth() >= 0 ? crop.getTargetWidth() : info.getWidth();
ht = crop.getTargetHeight() >= 0 ? crop.getTargetHeight() : info.getHeight();
transforms.add(new CmsBoxFit(CmsBoxFit.Mode.scaleOnlyIfNecessary, wv, hv, wt, ht));
if (crop.isCropped()) {
transforms.add(
new CmsBoxFit(CmsBoxFit.Mode.scaleAlways, wt, ht, crop.getCropWidth(), crop.getCropHeight()));
transforms.add(new CmsTranslate(crop.getCropX(), crop.getCropY()));
} else {
transforms.add(
new CmsBoxFit(CmsBoxFit.Mode.scaleAlways, wt, ht, crop.getOrgWidth(), crop.getOrgHeight()));
}
}
CmsCompositeTransform chain = new CmsCompositeTransform(transforms);
m_coordinateTransform = chain;
if ((crop == null) || !crop.isCropped()) {
m_region = transformRegionBack(
m_coordinateTransform,
CmsRectangle.fromLeftTopWidthHeight(0, 0, info.getWidth(), info.getHeight()));
} else {
m_region = transformRegionBack(
m_coordinateTransform,
CmsRectangle.fromLeftTopWidthHeight(
crop.getCropX(),
crop.getCropY(),
crop.getCropWidth(),
crop.getCropHeight()));
}
} | [
"private",
"void",
"updateScaling",
"(",
")",
"{",
"List",
"<",
"I_CmsTransform",
">",
"transforms",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"CmsCroppingParamBean",
"crop",
"=",
"m_croppingProvider",
".",
"get",
"(",
")",
";",
"CmsImageInfoBean",
"info",... | Sets up the coordinate transformations between the coordinate system of the parent element of the image element and the native coordinate system
of the original image. | [
"Sets",
"up",
"the",
"coordinate",
"transformations",
"between",
"the",
"coordinate",
"system",
"of",
"the",
"parent",
"element",
"of",
"the",
"image",
"element",
"and",
"the",
"native",
"coordinate",
"system",
"of",
"the",
"original",
"image",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/galleries/client/preview/CmsFocalPointController.java#L439-L479 | train |
alkacon/opencms-core | src/org/opencms/util/CmsFileUtil.java | CmsFileUtil.getEncoding | public static String getEncoding(CmsObject cms, CmsResource file) {
CmsProperty encodingProperty = CmsProperty.getNullProperty();
try {
encodingProperty = cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true);
} catch (CmsException e) {
LOG.debug(e.getLocalizedMessage(), e);
}
return CmsEncoder.lookupEncoding(encodingProperty.getValue(""), OpenCms.getSystemInfo().getDefaultEncoding());
} | java | public static String getEncoding(CmsObject cms, CmsResource file) {
CmsProperty encodingProperty = CmsProperty.getNullProperty();
try {
encodingProperty = cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true);
} catch (CmsException e) {
LOG.debug(e.getLocalizedMessage(), e);
}
return CmsEncoder.lookupEncoding(encodingProperty.getValue(""), OpenCms.getSystemInfo().getDefaultEncoding());
} | [
"public",
"static",
"String",
"getEncoding",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"file",
")",
"{",
"CmsProperty",
"encodingProperty",
"=",
"CmsProperty",
".",
"getNullProperty",
"(",
")",
";",
"try",
"{",
"encodingProperty",
"=",
"cms",
".",
"readProper... | Returns the encoding of the file.
Encoding is read from the content-encoding property and defaults to the systems default encoding.
Since properties can change without rewriting content, the actual encoding can differ.
@param cms {@link CmsObject} used to read properties of the given file.
@param file the file for which the encoding is requested
@return the file's encoding according to the content-encoding property, or the system's default encoding as default. | [
"Returns",
"the",
"encoding",
"of",
"the",
"file",
".",
"Encoding",
"is",
"read",
"from",
"the",
"content",
"-",
"encoding",
"property",
"and",
"defaults",
"to",
"the",
"systems",
"default",
"encoding",
".",
"Since",
"properties",
"can",
"change",
"without",
... | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/util/CmsFileUtil.java#L293-L302 | train |
alkacon/opencms-core | src/org/opencms/workplace/editors/CmsWorkplaceEditorManager.java | CmsWorkplaceEditorManager.getEditorParameter | public String getEditorParameter(CmsObject cms, String editor, String param) {
String path = OpenCms.getSystemInfo().getConfigFilePath(cms, "editors/" + editor + ".properties");
CmsVfsMemoryObjectCache cache = CmsVfsMemoryObjectCache.getVfsMemoryObjectCache();
CmsParameterConfiguration config = (CmsParameterConfiguration)cache.getCachedObject(cms, path);
if (config == null) {
try {
CmsFile file = cms.readFile(path);
try (ByteArrayInputStream input = new ByteArrayInputStream(file.getContents())) {
config = new CmsParameterConfiguration(input); // Uses ISO-8859-1, should be OK for config parameters
cache.putCachedObject(cms, path, config);
}
} catch (CmsVfsResourceNotFoundException e) {
return null;
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
return null;
}
}
return config.getString(param, null);
} | java | public String getEditorParameter(CmsObject cms, String editor, String param) {
String path = OpenCms.getSystemInfo().getConfigFilePath(cms, "editors/" + editor + ".properties");
CmsVfsMemoryObjectCache cache = CmsVfsMemoryObjectCache.getVfsMemoryObjectCache();
CmsParameterConfiguration config = (CmsParameterConfiguration)cache.getCachedObject(cms, path);
if (config == null) {
try {
CmsFile file = cms.readFile(path);
try (ByteArrayInputStream input = new ByteArrayInputStream(file.getContents())) {
config = new CmsParameterConfiguration(input); // Uses ISO-8859-1, should be OK for config parameters
cache.putCachedObject(cms, path, config);
}
} catch (CmsVfsResourceNotFoundException e) {
return null;
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
return null;
}
}
return config.getString(param, null);
} | [
"public",
"String",
"getEditorParameter",
"(",
"CmsObject",
"cms",
",",
"String",
"editor",
",",
"String",
"param",
")",
"{",
"String",
"path",
"=",
"OpenCms",
".",
"getSystemInfo",
"(",
")",
".",
"getConfigFilePath",
"(",
"cms",
",",
"\"editors/\"",
"+",
"e... | Gets the value of a global editor configuration parameter.
@param cms the CMS context
@param editor the editor name
@param param the name of the parameter
@return the editor parameter value | [
"Gets",
"the",
"value",
"of",
"a",
"global",
"editor",
"configuration",
"parameter",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/editors/CmsWorkplaceEditorManager.java#L250-L270 | train |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspInstanceDateBean.java | CmsJspInstanceDateBean.getEnd | public Date getEnd() {
if (null != m_explicitEnd) {
return isWholeDay() ? adjustForWholeDay(m_explicitEnd, true) : m_explicitEnd;
}
if ((null == m_end) && (m_series.getInstanceDuration() != null)) {
m_end = new Date(m_start.getTime() + m_series.getInstanceDuration().longValue());
}
return isWholeDay() && !m_series.isWholeDay() ? adjustForWholeDay(m_end, true) : m_end;
} | java | public Date getEnd() {
if (null != m_explicitEnd) {
return isWholeDay() ? adjustForWholeDay(m_explicitEnd, true) : m_explicitEnd;
}
if ((null == m_end) && (m_series.getInstanceDuration() != null)) {
m_end = new Date(m_start.getTime() + m_series.getInstanceDuration().longValue());
}
return isWholeDay() && !m_series.isWholeDay() ? adjustForWholeDay(m_end, true) : m_end;
} | [
"public",
"Date",
"getEnd",
"(",
")",
"{",
"if",
"(",
"null",
"!=",
"m_explicitEnd",
")",
"{",
"return",
"isWholeDay",
"(",
")",
"?",
"adjustForWholeDay",
"(",
"m_explicitEnd",
",",
"true",
")",
":",
"m_explicitEnd",
";",
"}",
"if",
"(",
"(",
"null",
"... | Returns the end time of the event.
@return the end time of the event. | [
"Returns",
"the",
"end",
"time",
"of",
"the",
"event",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspInstanceDateBean.java#L239-L248 | train |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspInstanceDateBean.java | CmsJspInstanceDateBean.setEnd | public void setEnd(Date endDate) {
if ((null == endDate) || getStart().after(endDate)) {
m_explicitEnd = null;
} else {
m_explicitEnd = endDate;
}
} | java | public void setEnd(Date endDate) {
if ((null == endDate) || getStart().after(endDate)) {
m_explicitEnd = null;
} else {
m_explicitEnd = endDate;
}
} | [
"public",
"void",
"setEnd",
"(",
"Date",
"endDate",
")",
"{",
"if",
"(",
"(",
"null",
"==",
"endDate",
")",
"||",
"getStart",
"(",
")",
".",
"after",
"(",
"endDate",
")",
")",
"{",
"m_explicitEnd",
"=",
"null",
";",
"}",
"else",
"{",
"m_explicitEnd",... | Explicitly set the end time of the event.
If the provided date is <code>null</code> or a date before the start date, the end date defaults to the start date.
@param endDate the end time of the event. | [
"Explicitly",
"set",
"the",
"end",
"time",
"of",
"the",
"event",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspInstanceDateBean.java#L363-L370 | train |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspInstanceDateBean.java | CmsJspInstanceDateBean.adjustForWholeDay | private Date adjustForWholeDay(Date date, boolean isEnd) {
Calendar result = new GregorianCalendar();
result.setTime(date);
result.set(Calendar.HOUR_OF_DAY, 0);
result.set(Calendar.MINUTE, 0);
result.set(Calendar.SECOND, 0);
result.set(Calendar.MILLISECOND, 0);
if (isEnd) {
result.add(Calendar.DATE, 1);
}
return result.getTime();
} | java | private Date adjustForWholeDay(Date date, boolean isEnd) {
Calendar result = new GregorianCalendar();
result.setTime(date);
result.set(Calendar.HOUR_OF_DAY, 0);
result.set(Calendar.MINUTE, 0);
result.set(Calendar.SECOND, 0);
result.set(Calendar.MILLISECOND, 0);
if (isEnd) {
result.add(Calendar.DATE, 1);
}
return result.getTime();
} | [
"private",
"Date",
"adjustForWholeDay",
"(",
"Date",
"date",
",",
"boolean",
"isEnd",
")",
"{",
"Calendar",
"result",
"=",
"new",
"GregorianCalendar",
"(",
")",
";",
"result",
".",
"setTime",
"(",
"date",
")",
";",
"result",
".",
"set",
"(",
"Calendar",
... | Adjust the date according to the whole day options.
@param date the date to adjust.
@param isEnd flag, indicating if the date is the end of the event (in contrast to the beginning)
@return the adjusted date, which will be exactly the beginning or the end of the provide date's day. | [
"Adjust",
"the",
"date",
"according",
"to",
"the",
"whole",
"day",
"options",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspInstanceDateBean.java#L428-L441 | train |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspInstanceDateBean.java | CmsJspInstanceDateBean.isSingleMultiDay | private boolean isSingleMultiDay() {
long duration = getEnd().getTime() - getStart().getTime();
if (duration > I_CmsSerialDateValue.DAY_IN_MILLIS) {
return true;
}
if (isWholeDay() && (duration <= I_CmsSerialDateValue.DAY_IN_MILLIS)) {
return false;
}
Calendar start = new GregorianCalendar();
start.setTime(getStart());
Calendar end = new GregorianCalendar();
end.setTime(getEnd());
if (start.get(Calendar.DAY_OF_MONTH) == end.get(Calendar.DAY_OF_MONTH)) {
return false;
}
return true;
} | java | private boolean isSingleMultiDay() {
long duration = getEnd().getTime() - getStart().getTime();
if (duration > I_CmsSerialDateValue.DAY_IN_MILLIS) {
return true;
}
if (isWholeDay() && (duration <= I_CmsSerialDateValue.DAY_IN_MILLIS)) {
return false;
}
Calendar start = new GregorianCalendar();
start.setTime(getStart());
Calendar end = new GregorianCalendar();
end.setTime(getEnd());
if (start.get(Calendar.DAY_OF_MONTH) == end.get(Calendar.DAY_OF_MONTH)) {
return false;
}
return true;
} | [
"private",
"boolean",
"isSingleMultiDay",
"(",
")",
"{",
"long",
"duration",
"=",
"getEnd",
"(",
")",
".",
"getTime",
"(",
")",
"-",
"getStart",
"(",
")",
".",
"getTime",
"(",
")",
";",
"if",
"(",
"duration",
">",
"I_CmsSerialDateValue",
".",
"DAY_IN_MIL... | Returns a flag, indicating if the current event is a multi-day event.
The method is only called if the single event has an explicitely set end date
or an explicitely changed whole day option.
@return a flag, indicating if the current event takes lasts over more than one day. | [
"Returns",
"a",
"flag",
"indicating",
"if",
"the",
"current",
"event",
"is",
"a",
"multi",
"-",
"day",
"event",
".",
"The",
"method",
"is",
"only",
"called",
"if",
"the",
"single",
"event",
"has",
"an",
"explicitely",
"set",
"end",
"date",
"or",
"an",
... | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspInstanceDateBean.java#L481-L499 | train |
alkacon/opencms-core | src/org/opencms/ugc/CmsUgcSessionSecurityUtil.java | CmsUgcSessionSecurityUtil.checkCreateUpload | public static void checkCreateUpload(CmsObject cms, CmsUgcConfiguration config, String name, long size)
throws CmsUgcException {
if (!config.getUploadParentFolder().isPresent()) {
String message = Messages.get().container(Messages.ERR_NO_UPLOADS_ALLOWED_0).key(
cms.getRequestContext().getLocale());
throw new CmsUgcException(CmsUgcConstants.ErrorCode.errNoUploadAllowed, message);
}
if (config.getMaxUploadSize().isPresent()) {
if (config.getMaxUploadSize().get().longValue() < size) {
String message = Messages.get().container(Messages.ERR_UPLOAD_TOO_BIG_1, name).key(
cms.getRequestContext().getLocale());
throw new CmsUgcException(CmsUgcConstants.ErrorCode.errMaxUploadSizeExceeded, message);
}
}
if (config.getValidExtensions().isPresent()) {
List<String> validExtensions = config.getValidExtensions().get();
boolean foundExtension = false;
for (String extension : validExtensions) {
if (name.toLowerCase().endsWith(extension.toLowerCase())) {
foundExtension = true;
break;
}
}
if (!foundExtension) {
String message = Messages.get().container(Messages.ERR_UPLOAD_FILE_EXTENSION_NOT_ALLOWED_1, name).key(
cms.getRequestContext().getLocale());
throw new CmsUgcException(CmsUgcConstants.ErrorCode.errInvalidExtension, message);
}
}
} | java | public static void checkCreateUpload(CmsObject cms, CmsUgcConfiguration config, String name, long size)
throws CmsUgcException {
if (!config.getUploadParentFolder().isPresent()) {
String message = Messages.get().container(Messages.ERR_NO_UPLOADS_ALLOWED_0).key(
cms.getRequestContext().getLocale());
throw new CmsUgcException(CmsUgcConstants.ErrorCode.errNoUploadAllowed, message);
}
if (config.getMaxUploadSize().isPresent()) {
if (config.getMaxUploadSize().get().longValue() < size) {
String message = Messages.get().container(Messages.ERR_UPLOAD_TOO_BIG_1, name).key(
cms.getRequestContext().getLocale());
throw new CmsUgcException(CmsUgcConstants.ErrorCode.errMaxUploadSizeExceeded, message);
}
}
if (config.getValidExtensions().isPresent()) {
List<String> validExtensions = config.getValidExtensions().get();
boolean foundExtension = false;
for (String extension : validExtensions) {
if (name.toLowerCase().endsWith(extension.toLowerCase())) {
foundExtension = true;
break;
}
}
if (!foundExtension) {
String message = Messages.get().container(Messages.ERR_UPLOAD_FILE_EXTENSION_NOT_ALLOWED_1, name).key(
cms.getRequestContext().getLocale());
throw new CmsUgcException(CmsUgcConstants.ErrorCode.errInvalidExtension, message);
}
}
} | [
"public",
"static",
"void",
"checkCreateUpload",
"(",
"CmsObject",
"cms",
",",
"CmsUgcConfiguration",
"config",
",",
"String",
"name",
",",
"long",
"size",
")",
"throws",
"CmsUgcException",
"{",
"if",
"(",
"!",
"config",
".",
"getUploadParentFolder",
"(",
")",
... | Checks whether an uploaded file can be created in the VFS, and throws an exception otherwise.
@param cms the current CMS context
@param config the form configuration
@param name the file name of the uploaded file
@param size the size of the uploaded file
@throws CmsUgcException if something goes wrong | [
"Checks",
"whether",
"an",
"uploaded",
"file",
"can",
"be",
"created",
"in",
"the",
"VFS",
"and",
"throws",
"an",
"exception",
"otherwise",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ugc/CmsUgcSessionSecurityUtil.java#L95-L127 | train |
alkacon/opencms-core | src/org/opencms/jsp/search/controller/CmsSearchControllerFacetRange.java | CmsSearchControllerFacetRange.addFacetPart | protected void addFacetPart(CmsSolrQuery query) {
StringBuffer value = new StringBuffer();
value.append("{!key=").append(m_config.getName());
addFacetOptions(value);
if (m_config.getIgnoreAllFacetFilters()
|| (!m_state.getCheckedEntries().isEmpty() && !m_config.getIsAndFacet())) {
value.append(" ex=").append(m_config.getIgnoreTags());
}
value.append("}");
value.append(m_config.getRange());
query.add("facet.range", value.toString());
} | java | protected void addFacetPart(CmsSolrQuery query) {
StringBuffer value = new StringBuffer();
value.append("{!key=").append(m_config.getName());
addFacetOptions(value);
if (m_config.getIgnoreAllFacetFilters()
|| (!m_state.getCheckedEntries().isEmpty() && !m_config.getIsAndFacet())) {
value.append(" ex=").append(m_config.getIgnoreTags());
}
value.append("}");
value.append(m_config.getRange());
query.add("facet.range", value.toString());
} | [
"protected",
"void",
"addFacetPart",
"(",
"CmsSolrQuery",
"query",
")",
"{",
"StringBuffer",
"value",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"value",
".",
"append",
"(",
"\"{!key=\"",
")",
".",
"append",
"(",
"m_config",
".",
"getName",
"(",
")",
")",
... | Generate query part for the facet, without filters.
@param query The query, where the facet part should be added | [
"Generate",
"query",
"part",
"for",
"the",
"facet",
"without",
"filters",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/controller/CmsSearchControllerFacetRange.java#L162-L174 | train |
alkacon/opencms-core | src/org/opencms/widgets/serialdate/CmsSerialDateBeanYearlyWeekday.java | CmsSerialDateBeanYearlyWeekday.setFittingWeekDay | private void setFittingWeekDay(Calendar date) {
date.set(Calendar.DAY_OF_MONTH, 1);
int weekDayFirst = date.get(Calendar.DAY_OF_WEEK);
int firstFittingWeekDay = (((m_weekDay.toInt() + I_CmsSerialDateValue.NUM_OF_WEEKDAYS) - weekDayFirst)
% I_CmsSerialDateValue.NUM_OF_WEEKDAYS) + 1;
int fittingWeekDay = firstFittingWeekDay + (I_CmsSerialDateValue.NUM_OF_WEEKDAYS * m_weekOfMonth.ordinal());
if (fittingWeekDay > date.getActualMaximum(Calendar.DAY_OF_MONTH)) {
fittingWeekDay -= I_CmsSerialDateValue.NUM_OF_WEEKDAYS;
}
date.set(Calendar.DAY_OF_MONTH, fittingWeekDay);
} | java | private void setFittingWeekDay(Calendar date) {
date.set(Calendar.DAY_OF_MONTH, 1);
int weekDayFirst = date.get(Calendar.DAY_OF_WEEK);
int firstFittingWeekDay = (((m_weekDay.toInt() + I_CmsSerialDateValue.NUM_OF_WEEKDAYS) - weekDayFirst)
% I_CmsSerialDateValue.NUM_OF_WEEKDAYS) + 1;
int fittingWeekDay = firstFittingWeekDay + (I_CmsSerialDateValue.NUM_OF_WEEKDAYS * m_weekOfMonth.ordinal());
if (fittingWeekDay > date.getActualMaximum(Calendar.DAY_OF_MONTH)) {
fittingWeekDay -= I_CmsSerialDateValue.NUM_OF_WEEKDAYS;
}
date.set(Calendar.DAY_OF_MONTH, fittingWeekDay);
} | [
"private",
"void",
"setFittingWeekDay",
"(",
"Calendar",
"date",
")",
"{",
"date",
".",
"set",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
",",
"1",
")",
";",
"int",
"weekDayFirst",
"=",
"date",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_WEEK",
")",
";",
"int",... | Adjusts the day in the provided month, that it fits the specified week day.
If there's no match for that provided month, the next possible month is checked.
@param date the date to adjust, with the correct year and month already set. | [
"Adjusts",
"the",
"day",
"in",
"the",
"provided",
"month",
"that",
"it",
"fits",
"the",
"specified",
"week",
"day",
".",
"If",
"there",
"s",
"no",
"match",
"for",
"that",
"provided",
"month",
"the",
"next",
"possible",
"month",
"is",
"checked",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/widgets/serialdate/CmsSerialDateBeanYearlyWeekday.java#L134-L145 | train |
alkacon/opencms-core | src/org/opencms/ui/apps/user/CmsUserTable.java | CmsUserTable.getEmptyLayout | public VerticalLayout getEmptyLayout() {
m_emptyLayout = CmsVaadinUtils.getInfoLayout(CmsOuTreeType.USER.getEmptyMessageKey());
setVisible(size() > 0);
m_emptyLayout.setVisible(size() == 0);
return m_emptyLayout;
} | java | public VerticalLayout getEmptyLayout() {
m_emptyLayout = CmsVaadinUtils.getInfoLayout(CmsOuTreeType.USER.getEmptyMessageKey());
setVisible(size() > 0);
m_emptyLayout.setVisible(size() == 0);
return m_emptyLayout;
} | [
"public",
"VerticalLayout",
"getEmptyLayout",
"(",
")",
"{",
"m_emptyLayout",
"=",
"CmsVaadinUtils",
".",
"getInfoLayout",
"(",
"CmsOuTreeType",
".",
"USER",
".",
"getEmptyMessageKey",
"(",
")",
")",
";",
"setVisible",
"(",
"size",
"(",
")",
">",
"0",
")",
"... | Layout which gets displayed if table is empty.
@see org.opencms.ui.apps.user.I_CmsFilterableTable#getEmptyLayout() | [
"Layout",
"which",
"gets",
"displayed",
"if",
"table",
"is",
"empty",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/user/CmsUserTable.java#L964-L970 | train |
alkacon/opencms-core | src/org/opencms/ui/apps/user/CmsUserTable.java | CmsUserTable.getVisibleUser | public List<CmsUser> getVisibleUser() {
if (!m_fullyLoaded) {
return m_users;
}
if (size() == m_users.size()) {
return m_users;
}
List<CmsUser> directs = new ArrayList<CmsUser>();
for (CmsUser user : m_users) {
if (!m_indirects.contains(user)) {
directs.add(user);
}
}
return directs;
} | java | public List<CmsUser> getVisibleUser() {
if (!m_fullyLoaded) {
return m_users;
}
if (size() == m_users.size()) {
return m_users;
}
List<CmsUser> directs = new ArrayList<CmsUser>();
for (CmsUser user : m_users) {
if (!m_indirects.contains(user)) {
directs.add(user);
}
}
return directs;
} | [
"public",
"List",
"<",
"CmsUser",
">",
"getVisibleUser",
"(",
")",
"{",
"if",
"(",
"!",
"m_fullyLoaded",
")",
"{",
"return",
"m_users",
";",
"}",
"if",
"(",
"size",
"(",
")",
"==",
"m_users",
".",
"size",
"(",
")",
")",
"{",
"return",
"m_users",
";... | Gets currently visible user.
@return List of user | [
"Gets",
"currently",
"visible",
"user",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/user/CmsUserTable.java#L977-L992 | train |
alkacon/opencms-core | src/org/opencms/ui/apps/user/CmsUserTable.java | CmsUserTable.getStatus | String getStatus(CmsUser user, boolean disabled, boolean newUser) {
if (disabled) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_DISABLED_0);
}
if (newUser) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_INACTIVE_0);
}
if (OpenCms.getLoginManager().isUserTempDisabled(user.getName())) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_UNLOCK_USER_STATUS_0);
}
if (isUserPasswordReset(user)) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_PASSWORT_RESET_0);
}
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_ACTIVE_0);
} | java | String getStatus(CmsUser user, boolean disabled, boolean newUser) {
if (disabled) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_DISABLED_0);
}
if (newUser) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_INACTIVE_0);
}
if (OpenCms.getLoginManager().isUserTempDisabled(user.getName())) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_UNLOCK_USER_STATUS_0);
}
if (isUserPasswordReset(user)) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_PASSWORT_RESET_0);
}
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_ACTIVE_0);
} | [
"String",
"getStatus",
"(",
"CmsUser",
"user",
",",
"boolean",
"disabled",
",",
"boolean",
"newUser",
")",
"{",
"if",
"(",
"disabled",
")",
"{",
"return",
"CmsVaadinUtils",
".",
"getMessageText",
"(",
"Messages",
".",
"GUI_USERMANAGEMENT_USER_DISABLED_0",
")",
"... | Returns status message.
@param user CmsUser
@param disabled boolean
@param newUser boolean
@return String | [
"Returns",
"status",
"message",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/user/CmsUserTable.java#L1351-L1366 | train |
alkacon/opencms-core | src/org/opencms/ui/apps/user/CmsUserTable.java | CmsUserTable.getStatusHelp | String getStatusHelp(CmsUser user, boolean disabled, boolean newUser) {
if (disabled) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_DISABLED_HELP_0);
}
if (newUser) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_INACTIVE_HELP_0);
}
if (isUserPasswordReset(user)) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_PASSWORT_RESET_HELP_0);
}
long lastLogin = user.getLastlogin();
return CmsVaadinUtils.getMessageText(
Messages.GUI_USERMANAGEMENT_USER_ACTIVE_HELP_1,
CmsDateUtil.getDateTime(new Date(lastLogin), DateFormat.SHORT, A_CmsUI.get().getLocale()));
} | java | String getStatusHelp(CmsUser user, boolean disabled, boolean newUser) {
if (disabled) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_DISABLED_HELP_0);
}
if (newUser) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_INACTIVE_HELP_0);
}
if (isUserPasswordReset(user)) {
return CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_PASSWORT_RESET_HELP_0);
}
long lastLogin = user.getLastlogin();
return CmsVaadinUtils.getMessageText(
Messages.GUI_USERMANAGEMENT_USER_ACTIVE_HELP_1,
CmsDateUtil.getDateTime(new Date(lastLogin), DateFormat.SHORT, A_CmsUI.get().getLocale()));
} | [
"String",
"getStatusHelp",
"(",
"CmsUser",
"user",
",",
"boolean",
"disabled",
",",
"boolean",
"newUser",
")",
"{",
"if",
"(",
"disabled",
")",
"{",
"return",
"CmsVaadinUtils",
".",
"getMessageText",
"(",
"Messages",
".",
"GUI_USERMANAGEMENT_USER_DISABLED_HELP_0",
... | Returns status help message.
@param user CmsUser
@param disabled boolean
@param newUser boolean
@return String | [
"Returns",
"status",
"help",
"message",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/user/CmsUserTable.java#L1376-L1391 | train |
alkacon/opencms-core | src/org/opencms/ui/apps/user/CmsUserTable.java | CmsUserTable.isUserPasswordReset | boolean isUserPasswordReset(CmsUser user) {
if (USER_PASSWORD_STATUS.containsKey(user.getId())) { //Check if user was checked before
if (!USER_PASSWORD_STATUS.get(user.getId()).booleanValue()) { // was false before, false->true is never done without changing map
return false;
}
if (m_checkedUserPasswordReset.contains(user.getId())) { //was true before, true->false happens when user resets password. Only check one time per table load.
return true; //Set gets flushed on reloading table
}
}
CmsUser currentUser = user;
if (user.getAdditionalInfo().size() < 3) {
try {
currentUser = m_cms.readUser(user.getId());
} catch (CmsException e) {
LOG.error("Can not read user", e);
}
}
if (currentUser.getAdditionalInfo(CmsUserSettings.ADDITIONAL_INFO_PASSWORD_RESET) != null) {
USER_PASSWORD_STATUS.put(currentUser.getId(), new Boolean(true));
m_checkedUserPasswordReset.add(currentUser.getId());
return true;
}
USER_PASSWORD_STATUS.put(currentUser.getId(), new Boolean(false));
return false;
} | java | boolean isUserPasswordReset(CmsUser user) {
if (USER_PASSWORD_STATUS.containsKey(user.getId())) { //Check if user was checked before
if (!USER_PASSWORD_STATUS.get(user.getId()).booleanValue()) { // was false before, false->true is never done without changing map
return false;
}
if (m_checkedUserPasswordReset.contains(user.getId())) { //was true before, true->false happens when user resets password. Only check one time per table load.
return true; //Set gets flushed on reloading table
}
}
CmsUser currentUser = user;
if (user.getAdditionalInfo().size() < 3) {
try {
currentUser = m_cms.readUser(user.getId());
} catch (CmsException e) {
LOG.error("Can not read user", e);
}
}
if (currentUser.getAdditionalInfo(CmsUserSettings.ADDITIONAL_INFO_PASSWORD_RESET) != null) {
USER_PASSWORD_STATUS.put(currentUser.getId(), new Boolean(true));
m_checkedUserPasswordReset.add(currentUser.getId());
return true;
}
USER_PASSWORD_STATUS.put(currentUser.getId(), new Boolean(false));
return false;
} | [
"boolean",
"isUserPasswordReset",
"(",
"CmsUser",
"user",
")",
"{",
"if",
"(",
"USER_PASSWORD_STATUS",
".",
"containsKey",
"(",
"user",
".",
"getId",
"(",
")",
")",
")",
"{",
"//Check if user was checked before",
"if",
"(",
"!",
"USER_PASSWORD_STATUS",
".",
"get... | Is the user password reset?
@param user User to check
@return boolean | [
"Is",
"the",
"user",
"password",
"reset?"
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/user/CmsUserTable.java#L1417-L1443 | train |
alkacon/opencms-core | src/org/opencms/search/galleries/CmsGallerySearchParameters.java | CmsGallerySearchParameters.getQuery | public CmsSolrQuery getQuery(CmsObject cms) {
final CmsSolrQuery query = new CmsSolrQuery();
// set categories
query.setCategories(m_categories);
// set container types
if (null != m_containerTypes) {
query.addFilterQuery(CmsSearchField.FIELD_CONTAINER_TYPES, m_containerTypes, false, false);
}
// Set date created time filter
query.addFilterQuery(
CmsSearchUtil.getDateCreatedTimeRangeFilterQuery(
CmsSearchField.FIELD_DATE_CREATED,
getDateCreatedRange().m_startTime,
getDateCreatedRange().m_endTime));
// Set date last modified time filter
query.addFilterQuery(
CmsSearchUtil.getDateCreatedTimeRangeFilterQuery(
CmsSearchField.FIELD_DATE_LASTMODIFIED,
getDateLastModifiedRange().m_startTime,
getDateLastModifiedRange().m_endTime));
// set scope / folders to search in
m_foldersToSearchIn = new ArrayList<String>();
addFoldersToSearchIn(m_folders);
addFoldersToSearchIn(m_galleries);
setSearchFolders(cms);
query.addFilterQuery(
CmsSearchField.FIELD_PARENT_FOLDERS,
new ArrayList<String>(m_foldersToSearchIn),
false,
true);
if (!m_ignoreSearchExclude) {
// Reference for the values: CmsGallerySearchIndex.java, field EXCLUDE_PROPERTY_VALUES
query.addFilterQuery(
"-" + CmsSearchField.FIELD_SEARCH_EXCLUDE,
Arrays.asList(
new String[] {
A_CmsSearchIndex.PROPERTY_SEARCH_EXCLUDE_VALUE_ALL,
A_CmsSearchIndex.PROPERTY_SEARCH_EXCLUDE_VALUE_GALLERY}),
false,
true);
}
// set matches per page
query.setRows(new Integer(m_matchesPerPage));
// set resource types
if (null != m_resourceTypes) {
List<String> resourceTypes = new ArrayList<>(m_resourceTypes);
if (m_resourceTypes.contains(CmsResourceTypeFunctionConfig.TYPE_NAME)
&& !m_resourceTypes.contains(CmsXmlDynamicFunctionHandler.TYPE_FUNCTION)) {
resourceTypes.add(CmsXmlDynamicFunctionHandler.TYPE_FUNCTION);
}
query.setResourceTypes(resourceTypes);
}
// set result page
query.setStart(new Integer((m_resultPage - 1) * m_matchesPerPage));
// set search locale
if (null != m_locale) {
query.setLocales(CmsLocaleManager.getLocale(m_locale));
}
// set search words
if (null != m_words) {
query.setQuery(m_words);
}
// set sort order
query.setSort(getSort().getFirst(), getSort().getSecond());
// set result collapsing by id
query.addFilterQuery("{!collapse field=id}");
query.setFields(CmsGallerySearchResult.getRequiredSolrFields());
if ((m_allowedFunctions != null) && !m_allowedFunctions.isEmpty()) {
String functionFilter = "((-type:("
+ CmsXmlDynamicFunctionHandler.TYPE_FUNCTION
+ " OR "
+ CmsResourceTypeFunctionConfig.TYPE_NAME
+ ")) OR (id:(";
Iterator<CmsUUID> it = m_allowedFunctions.iterator();
while (it.hasNext()) {
CmsUUID id = it.next();
functionFilter += id.toString();
if (it.hasNext()) {
functionFilter += " OR ";
}
}
functionFilter += ")))";
query.addFilterQuery(functionFilter);
}
return query;
} | java | public CmsSolrQuery getQuery(CmsObject cms) {
final CmsSolrQuery query = new CmsSolrQuery();
// set categories
query.setCategories(m_categories);
// set container types
if (null != m_containerTypes) {
query.addFilterQuery(CmsSearchField.FIELD_CONTAINER_TYPES, m_containerTypes, false, false);
}
// Set date created time filter
query.addFilterQuery(
CmsSearchUtil.getDateCreatedTimeRangeFilterQuery(
CmsSearchField.FIELD_DATE_CREATED,
getDateCreatedRange().m_startTime,
getDateCreatedRange().m_endTime));
// Set date last modified time filter
query.addFilterQuery(
CmsSearchUtil.getDateCreatedTimeRangeFilterQuery(
CmsSearchField.FIELD_DATE_LASTMODIFIED,
getDateLastModifiedRange().m_startTime,
getDateLastModifiedRange().m_endTime));
// set scope / folders to search in
m_foldersToSearchIn = new ArrayList<String>();
addFoldersToSearchIn(m_folders);
addFoldersToSearchIn(m_galleries);
setSearchFolders(cms);
query.addFilterQuery(
CmsSearchField.FIELD_PARENT_FOLDERS,
new ArrayList<String>(m_foldersToSearchIn),
false,
true);
if (!m_ignoreSearchExclude) {
// Reference for the values: CmsGallerySearchIndex.java, field EXCLUDE_PROPERTY_VALUES
query.addFilterQuery(
"-" + CmsSearchField.FIELD_SEARCH_EXCLUDE,
Arrays.asList(
new String[] {
A_CmsSearchIndex.PROPERTY_SEARCH_EXCLUDE_VALUE_ALL,
A_CmsSearchIndex.PROPERTY_SEARCH_EXCLUDE_VALUE_GALLERY}),
false,
true);
}
// set matches per page
query.setRows(new Integer(m_matchesPerPage));
// set resource types
if (null != m_resourceTypes) {
List<String> resourceTypes = new ArrayList<>(m_resourceTypes);
if (m_resourceTypes.contains(CmsResourceTypeFunctionConfig.TYPE_NAME)
&& !m_resourceTypes.contains(CmsXmlDynamicFunctionHandler.TYPE_FUNCTION)) {
resourceTypes.add(CmsXmlDynamicFunctionHandler.TYPE_FUNCTION);
}
query.setResourceTypes(resourceTypes);
}
// set result page
query.setStart(new Integer((m_resultPage - 1) * m_matchesPerPage));
// set search locale
if (null != m_locale) {
query.setLocales(CmsLocaleManager.getLocale(m_locale));
}
// set search words
if (null != m_words) {
query.setQuery(m_words);
}
// set sort order
query.setSort(getSort().getFirst(), getSort().getSecond());
// set result collapsing by id
query.addFilterQuery("{!collapse field=id}");
query.setFields(CmsGallerySearchResult.getRequiredSolrFields());
if ((m_allowedFunctions != null) && !m_allowedFunctions.isEmpty()) {
String functionFilter = "((-type:("
+ CmsXmlDynamicFunctionHandler.TYPE_FUNCTION
+ " OR "
+ CmsResourceTypeFunctionConfig.TYPE_NAME
+ ")) OR (id:(";
Iterator<CmsUUID> it = m_allowedFunctions.iterator();
while (it.hasNext()) {
CmsUUID id = it.next();
functionFilter += id.toString();
if (it.hasNext()) {
functionFilter += " OR ";
}
}
functionFilter += ")))";
query.addFilterQuery(functionFilter);
}
return query;
} | [
"public",
"CmsSolrQuery",
"getQuery",
"(",
"CmsObject",
"cms",
")",
"{",
"final",
"CmsSolrQuery",
"query",
"=",
"new",
"CmsSolrQuery",
"(",
")",
";",
"// set categories",
"query",
".",
"setCategories",
"(",
"m_categories",
")",
";",
"// set container types",
"if",... | Returns a CmsSolrQuery representation of this class.
@param cms the openCms object.
@return CmsSolrQuery representation of this class. | [
"Returns",
"a",
"CmsSolrQuery",
"representation",
"of",
"this",
"class",
"."
] | bc104acc75d2277df5864da939a1f2de5fdee504 | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/galleries/CmsGallerySearchParameters.java#L361-L463 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.