_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q1800 | CmsFavoriteEntry.updateContextAndGetFavoriteUrl | train | public String updateContextAndGetFavoriteUrl(CmsObject cms) throws CmsException {
CmsResourceFilter filter = CmsResourceFilter.IGNORE_EXPIRATION;
CmsProject project = null;
switch (getType()) {
case explorerFolder:
CmsResource folder = cms.readResource(getStructureId(), filter);
project = cms.readProject(getProjectId());
cms.getRequestContext().setSiteRoot(getSiteRoot());
cms.getRequestContext().setCurrentProject(project);
String explorerLink = CmsVaadinUtils.getWorkplaceLink()
+ "#!"
+ CmsFileExplorerConfiguration.APP_ID
+ "/"
+ getProjectId()
+ "!!"
+ getSiteRoot()
+ "!!"
+ cms.getSitePath(folder);
return explorerLink;
case page:
project = cms.readProject(getProjectId());
CmsResource target = cms.readResource(getStructureId(), filter);
CmsResource detailContent = null;
String link = null;
cms.getRequestContext().setCurrentProject(project);
cms.getRequestContext().setSiteRoot(getSiteRoot());
if (getDetailId() != null) {
detailContent = cms.readResource(getDetailId());
link = OpenCms.getLinkManager().substituteLinkForUnknownTarget(
cms,
cms.getSitePath(detailContent),
cms.getSitePath(target),
false);
} else {
link = OpenCms.getLinkManager().substituteLink(cms, target);
}
return link;
default:
return null;
}
} | java | {
"resource": ""
} |
q1801 | CmsToolBar.openFavoriteDialog | train | public static void openFavoriteDialog(CmsFileExplorer explorer) {
try {
CmsExplorerFavoriteContext context = new CmsExplorerFavoriteContext(A_CmsUI.getCmsObject(), explorer);
CmsFavoriteDialog dialog = new CmsFavoriteDialog(context, new CmsFavoriteDAO(A_CmsUI.getCmsObject()));
Window window = CmsBasicDialog.prepareWindow(DialogWidth.max);
window.setContent(dialog);
window.setCaption(CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_FAVORITES_DIALOG_TITLE_0));
A_CmsUI.get().addWindow(window);
window.center();
} catch (CmsException e) {
CmsErrorDialog.showErrorDialog(e);
}
} | java | {
"resource": ""
} |
q1802 | CmsMessageBundleEditorTypes.getDescriptor | train | public static CmsResource getDescriptor(CmsObject cms, String basename) {
CmsSolrQuery query = new CmsSolrQuery();
query.setResourceTypes(CmsMessageBundleEditorTypes.BundleType.DESCRIPTOR.toString());
query.setFilterQueries("filename:\"" + basename + CmsMessageBundleEditorTypes.Descriptor.POSTFIX + "\"");
query.add("fl", "path");
CmsSolrResultList results;
try {
boolean isOnlineProject = cms.getRequestContext().getCurrentProject().isOnlineProject();
String indexName = isOnlineProject
? CmsSolrIndex.DEFAULT_INDEX_NAME_ONLINE
: CmsSolrIndex.DEFAULT_INDEX_NAME_OFFLINE;
results = OpenCms.getSearchManager().getIndexSolr(indexName).search(cms, query, true, null, true, null);
} catch (CmsSearchException e) {
LOG.error(Messages.get().getBundle().key(Messages.ERR_BUNDLE_DESCRIPTOR_SEARCH_ERROR_0), e);
return null;
}
switch (results.size()) {
case 0:
return null;
case 1:
return results.get(0);
default:
String files = "";
for (CmsResource res : results) {
files += " " + res.getRootPath();
}
LOG.warn(Messages.get().getBundle().key(Messages.ERR_BUNDLE_DESCRIPTOR_NOT_UNIQUE_1, files));
return results.get(0);
}
} | java | {
"resource": ""
} |
q1803 | CmsMessageBundleEditorTypes.showWarning | train | static void showWarning(final String caption, final String description) {
Notification warning = new Notification(caption, description, Type.WARNING_MESSAGE, true);
warning.setDelayMsec(-1);
warning.show(UI.getCurrent().getPage());
} | java | {
"resource": ""
} |
q1804 | CmsDateBox.setDateOnly | train | public void setDateOnly(boolean dateOnly) {
if (m_dateOnly != dateOnly) {
m_dateOnly = dateOnly;
if (m_dateOnly) {
m_time.removeFromParent();
m_am.removeFromParent();
m_pm.removeFromParent();
} else {
m_timeField.add(m_time);
m_timeField.add(m_am);
m_timeField.add(m_pm);
}
}
} | java | {
"resource": ""
} |
q1805 | CmsPatternPanelIndividualView.addButtonClick | train | @UiHandler("m_addButton")
void addButtonClick(ClickEvent e) {
if (null != m_newDate.getValue()) {
m_dateList.addDate(m_newDate.getValue());
m_newDate.setValue(null);
if (handleChange()) {
m_controller.setDates(m_dateList.getDates());
}
}
} | java | {
"resource": ""
} |
q1806 | CmsPatternPanelIndividualView.dateListValueChange | train | @UiHandler("m_dateList")
void dateListValueChange(ValueChangeEvent<SortedSet<Date>> event) {
if (handleChange()) {
m_controller.setDates(event.getValue());
}
} | java | {
"resource": ""
} |
q1807 | CmsParameterConfiguration.remove | train | @Override
public String remove(Object key) {
String result = m_configurationStrings.remove(key);
m_configurationObjects.remove(key);
return result;
} | java | {
"resource": ""
} |
q1808 | OpenCmsServlet.loadCustomErrorPage | train | private boolean loadCustomErrorPage(
CmsObject cms,
HttpServletRequest req,
HttpServletResponse res,
String rootPath) {
try {
// get the site of the error page resource
CmsSite errorSite = OpenCms.getSiteManager().getSiteForRootPath(rootPath);
cms.getRequestContext().setSiteRoot(errorSite.getSiteRoot());
String relPath = cms.getRequestContext().removeSiteRoot(rootPath);
if (cms.existsResource(relPath)) {
cms.getRequestContext().setUri(relPath);
OpenCms.getResourceManager().loadResource(cms, cms.readResource(relPath), req, res);
return true;
} else {
return false;
}
} catch (Throwable e) {
// something went wrong log the exception and return false
LOG.error(e.getMessage(), e);
return false;
}
} | java | {
"resource": ""
} |
q1809 | OpenCmsServlet.tryCustomErrorPage | train | private boolean tryCustomErrorPage(CmsObject cms, HttpServletRequest req, HttpServletResponse res, int errorCode) {
String siteRoot = OpenCms.getSiteManager().matchRequest(req).getSiteRoot();
CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot);
if (site != null) {
// store current site root and URI
String currentSiteRoot = cms.getRequestContext().getSiteRoot();
String currentUri = cms.getRequestContext().getUri();
try {
if (site.getErrorPage() != null) {
String rootPath = site.getErrorPage();
if (loadCustomErrorPage(cms, req, res, rootPath)) {
return true;
}
}
String rootPath = CmsStringUtil.joinPaths(siteRoot, "/.errorpages/handle" + errorCode + ".html");
if (loadCustomErrorPage(cms, req, res, rootPath)) {
return true;
}
} finally {
cms.getRequestContext().setSiteRoot(currentSiteRoot);
cms.getRequestContext().setUri(currentUri);
}
}
return false;
} | java | {
"resource": ""
} |
q1810 | CmsGalleryService.buildVfsEntryBeanForQuickSearch | train | private CmsVfsEntryBean buildVfsEntryBeanForQuickSearch(
CmsResource resource,
Multimap<CmsResource, CmsResource> childMap,
Set<CmsResource> filterMatches,
Set<String> parentPaths,
boolean isRoot)
throws CmsException {
CmsObject cms = getCmsObject();
String title = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue();
boolean isMatch = filterMatches.contains(resource);
List<CmsVfsEntryBean> childBeans = Lists.newArrayList();
Collection<CmsResource> children = childMap.get(resource);
if (!children.isEmpty()) {
for (CmsResource child : children) {
CmsVfsEntryBean childBean = buildVfsEntryBeanForQuickSearch(
child,
childMap,
filterMatches,
parentPaths,
false);
childBeans.add(childBean);
}
} else if (filterMatches.contains(resource)) {
if (parentPaths.contains(resource.getRootPath())) {
childBeans = null;
}
// otherwise childBeans remains an empty list
}
String rootPath = resource.getRootPath();
CmsVfsEntryBean result = new CmsVfsEntryBean(
rootPath,
resource.getStructureId(),
title,
CmsIconUtil.getIconClasses(CmsIconUtil.getDisplayType(cms, resource), resource.getName(), true),
isRoot,
isEditable(cms, resource),
childBeans,
isMatch);
String siteRoot = null;
if (OpenCms.getSiteManager().startsWithShared(rootPath)) {
siteRoot = OpenCms.getSiteManager().getSharedFolder();
} else {
String tempSiteRoot = OpenCms.getSiteManager().getSiteRoot(rootPath);
if (tempSiteRoot != null) {
siteRoot = tempSiteRoot;
} else {
siteRoot = "";
}
}
result.setSiteRoot(siteRoot);
return result;
} | java | {
"resource": ""
} |
q1811 | CmsJspLoader.doPurge | train | protected void doPurge(Runnable afterPurgeAction) {
if (LOG.isInfoEnabled()) {
LOG.info(
org.opencms.flex.Messages.get().getBundle().key(
org.opencms.flex.Messages.LOG_FLEXCACHE_WILL_PURGE_JSP_REPOSITORY_0));
}
File d;
d = new File(getJspRepository() + CmsFlexCache.REPOSITORY_ONLINE + File.separator);
CmsFileUtil.purgeDirectory(d);
d = new File(getJspRepository() + CmsFlexCache.REPOSITORY_OFFLINE + File.separator);
CmsFileUtil.purgeDirectory(d);
if (afterPurgeAction != null) {
afterPurgeAction.run();
}
if (LOG.isInfoEnabled()) {
LOG.info(
org.opencms.flex.Messages.get().getBundle().key(
org.opencms.flex.Messages.LOG_FLEXCACHE_PURGED_JSP_REPOSITORY_0));
}
} | java | {
"resource": ""
} |
q1812 | CmsRemoteShellClient.wrongUsage | train | private void wrongUsage() {
String usage = "Usage: java -cp $PATH_TO_OPENCMS_JAR org.opencms.rmi.CmsRemoteShellClient\n"
+ " -script=[path to script] (optional) \n"
+ " -registryPort=[port of RMI registry] (optional, default is "
+ CmsRemoteShellConstants.DEFAULT_PORT
+ ")\n"
+ " -additional=[additional commands class name] (optional)";
System.out.println(usage);
System.exit(1);
} | java | {
"resource": ""
} |
q1813 | CmsJspTagSearch.setAddContentInfo | train | public void setAddContentInfo(final Boolean doAddInfo) {
if ((null != doAddInfo) && doAddInfo.booleanValue() && (null != m_addContentInfoForEntries)) {
m_addContentInfoForEntries = Integer.valueOf(DEFAULT_CONTENTINFO_ROWS);
}
} | java | {
"resource": ""
} |
q1814 | CmsJspTagSearch.setFileFormat | train | public void setFileFormat(String fileFormat) {
if (fileFormat.toUpperCase().equals(FileFormat.JSON.toString())) {
m_fileFormat = FileFormat.JSON;
}
} | java | {
"resource": ""
} |
q1815 | CmsJspTagSearch.addContentInfo | train | private void addContentInfo() {
if (!m_cms.getRequestContext().getCurrentProject().isOnlineProject()
&& (null == m_searchController.getCommon().getConfig().getSolrIndex())
&& (null != m_addContentInfoForEntries)) {
CmsSolrQuery query = new CmsSolrQuery();
m_searchController.addQueryParts(query, m_cms);
query.setStart(Integer.valueOf(0));
query.setRows(m_addContentInfoForEntries);
CmsContentLoadCollectorInfo info = new CmsContentLoadCollectorInfo();
info.setCollectorClass(this.getClass().getName());
info.setCollectorParams(query.getQuery());
info.setId((new CmsUUID()).getStringValue());
if (CmsJspTagEditable.getDirectEditProvider(pageContext) != null) {
try {
CmsJspTagEditable.getDirectEditProvider(pageContext).insertDirectEditListMetadata(
pageContext,
info);
} catch (JspException e) {
LOG.error("Could not write content info.", e);
}
}
}
} | java | {
"resource": ""
} |
q1816 | CmsJspTagSearch.getSearchResults | train | private I_CmsSearchResultWrapper getSearchResults() {
// The second parameter is just ignored - so it does not matter
m_searchController.updateFromRequestParameters(pageContext.getRequest().getParameterMap(), false);
I_CmsSearchControllerCommon common = m_searchController.getCommon();
// Do not search for empty query, if configured
if (common.getState().getQuery().isEmpty()
&& (!common.getConfig().getIgnoreQueryParam() && !common.getConfig().getSearchForEmptyQueryParam())) {
return new CmsSearchResultWrapper(m_searchController, null, null, m_cms, null);
}
Map<String, String[]> queryParams = null;
boolean isEditMode = CmsJspTagEditable.isEditableRequest(pageContext.getRequest());
if (isEditMode) {
String params = "";
if (common.getConfig().getIgnoreReleaseDate()) {
params += "&fq=released:[* TO *]";
}
if (common.getConfig().getIgnoreExpirationDate()) {
params += "&fq=expired:[* TO *]";
}
if (!params.isEmpty()) {
queryParams = CmsRequestUtil.createParameterMap(params.substring(1));
}
}
CmsSolrQuery query = new CmsSolrQuery(null, queryParams);
m_searchController.addQueryParts(query, m_cms);
try {
// use "complicated" constructor to allow more than 50 results -> set ignoreMaxResults to true
// also set resource filter to allow for returning unreleased/expired resources if necessary.
CmsSolrResultList solrResultList = m_index.search(
m_cms,
query.clone(), // use a clone of the query, since the search function manipulates the query (removes highlighting parts), but we want to keep the original one.
true,
isEditMode ? CmsResourceFilter.IGNORE_EXPIRATION : null);
return new CmsSearchResultWrapper(m_searchController, solrResultList, query, m_cms, null);
} catch (CmsSearchException e) {
LOG.warn(Messages.get().getBundle().key(Messages.LOG_TAG_SEARCH_SEARCH_FAILED_0), e);
return new CmsSearchResultWrapper(m_searchController, null, query, m_cms, e);
}
} | java | {
"resource": ""
} |
q1817 | CmsJspDateSeriesBean.toDate | train | public Date toDate(Object date) {
Date d = null;
if (null != date) {
if (date instanceof Date) {
d = (Date)date;
} else if (date instanceof Long) {
d = new Date(((Long)date).longValue());
} else {
try {
long l = Long.parseLong(date.toString());
d = new Date(l);
} catch (Exception e) {
// do nothing, just let d remain null
}
}
}
return d;
} | java | {
"resource": ""
} |
q1818 | CmsJlanThreadManager.stop | train | public synchronized void stop() {
if (m_thread != null) {
long timeBeforeShutdownWasCalled = System.currentTimeMillis();
JLANServer.shutdownServer(new String[] {});
while (m_thread.isAlive()
&& ((System.currentTimeMillis() - timeBeforeShutdownWasCalled) < MAX_SHUTDOWN_WAIT_MILLIS)) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// ignore
}
}
}
} | java | {
"resource": ""
} |
q1819 | CmsUpdateInfo.needToSetCategoryFolder | train | public boolean needToSetCategoryFolder() {
if (m_adeModuleVersion == null) {
return true;
}
CmsModuleVersion categoryFolderUpdateVersion = new CmsModuleVersion("9.0.0");
return (m_adeModuleVersion.compareTo(categoryFolderUpdateVersion) == -1);
} | java | {
"resource": ""
} |
q1820 | CmsPatternPanelWeeklyController.setWeekDays | train | public void setWeekDays(SortedSet<WeekDay> weekDays) {
final SortedSet<WeekDay> newWeekDays = null == weekDays ? new TreeSet<WeekDay>() : weekDays;
SortedSet<WeekDay> currentWeekDays = m_model.getWeekDays();
if (!currentWeekDays.equals(newWeekDays)) {
conditionallyRemoveExceptionsOnChange(new Command() {
public void execute() {
m_model.setWeekDays(newWeekDays);
onValueChange();
}
}, !newWeekDays.containsAll(m_model.getWeekDays()));
}
} | java | {
"resource": ""
} |
q1821 | CmsUserEditDialog.switchTab | train | protected void switchTab() {
Component tab = m_tab.getSelectedTab();
int pos = m_tab.getTabPosition(m_tab.getTab(tab));
if (m_isWebOU) {
if (pos == 0) {
pos = 1;
}
}
m_tab.setSelectedTab(pos + 1);
} | java | {
"resource": ""
} |
q1822 | CmsListItemWidget.onEditTitleTextBox | train | protected void onEditTitleTextBox(TextBox box) {
if (m_titleEditHandler != null) {
m_titleEditHandler.handleEdit(m_title, box);
return;
}
String text = box.getText();
box.removeFromParent();
m_title.setText(text);
m_title.setVisible(true);
} | java | {
"resource": ""
} |
q1823 | CmsPatternPanelMonthlyController.setPatternScheme | train | public void setPatternScheme(final boolean isByWeekDay, final boolean fireChange) {
if (isByWeekDay ^ (null != m_model.getWeekDay())) {
removeExceptionsOnChange(new Command() {
public void execute() {
if (isByWeekDay) {
m_model.setWeekOfMonth(getPatternDefaultValues().getWeekOfMonth());
m_model.setWeekDay(getPatternDefaultValues().getWeekDay());
} else {
m_model.clearWeekDays();
m_model.clearWeeksOfMonth();
m_model.setDayOfMonth(getPatternDefaultValues().getDayOfMonth());
}
m_model.setInterval(getPatternDefaultValues().getInterval());
if (fireChange) {
onValueChange();
}
}
});
}
} | java | {
"resource": ""
} |
q1824 | CmsPatternPanelMonthlyController.setWeekDay | train | public void setWeekDay(String dayString) {
final WeekDay day = WeekDay.valueOf(dayString);
if (m_model.getWeekDay() != day) {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.setWeekDay(day);
onValueChange();
}
});
}
} | java | {
"resource": ""
} |
q1825 | CmsPatternPanelMonthlyController.weeksChange | train | public void weeksChange(String week, Boolean value) {
final WeekOfMonth changedWeek = WeekOfMonth.valueOf(week);
boolean newValue = (null != value) && value.booleanValue();
boolean currentValue = m_model.getWeeksOfMonth().contains(changedWeek);
if (newValue != currentValue) {
if (newValue) {
setPatternScheme(true, false);
m_model.addWeekOfMonth(changedWeek);
onValueChange();
} else {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.removeWeekOfMonth(changedWeek);
onValueChange();
}
});
}
}
} | java | {
"resource": ""
} |
q1826 | CmsAliasList.validateAliases | train | public void validateAliases(
final CmsUUID uuid,
final Map<String, String> aliasPaths,
final AsyncCallback<Map<String, String>> callback) {
CmsRpcAction<Map<String, String>> action = new CmsRpcAction<Map<String, String>>() {
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
*/
@Override
public void execute() {
start(200, true);
CmsCoreProvider.getVfsService().validateAliases(uuid, aliasPaths, this);
}
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
*/
@Override
protected void onResponse(Map<String, String> result) {
stop(false);
callback.onSuccess(result);
}
};
action.execute();
} | java | {
"resource": ""
} |
q1827 | A_CmsPatternPanelController.setDayOfMonth | train | void setDayOfMonth(String day) {
final int i = CmsSerialDateUtil.toIntWithDefault(day, -1);
if (m_model.getDayOfMonth() != i) {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.setDayOfMonth(i);
onValueChange();
}
});
}
} | java | {
"resource": ""
} |
q1828 | CmsStreamReportWidget.convertOutputToHtml | train | private String convertOutputToHtml(String content) {
if (content.length() == 0) {
return "";
}
StringBuilder buffer = new StringBuilder();
for (String line : content.split("\n")) {
buffer.append(CmsEncoder.escapeXml(line) + "<br>");
}
return buffer.toString();
} | java | {
"resource": ""
} |
q1829 | CmsStreamReportWidget.writeToDelegate | train | private void writeToDelegate(byte[] data) {
if (m_delegateStream != null) {
try {
m_delegateStream.write(data);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
} | java | {
"resource": ""
} |
q1830 | CmsUserInfoDialog.getStatusForItem | train | public static String getStatusForItem(Long lastActivity) {
if (lastActivity.longValue() < CmsSessionsTable.INACTIVE_LIMIT) {
return CmsVaadinUtils.getMessageText(Messages.GUI_MESSAGES_BROADCAST_COLS_STATUS_ACTIVE_0);
}
return CmsVaadinUtils.getMessageText(Messages.GUI_MESSAGES_BROADCAST_COLS_STATUS_INACTIVE_0);
} | java | {
"resource": ""
} |
q1831 | CmsUserInfoDialog.showUserInfo | train | public static void showUserInfo(CmsSessionInfo session) {
final Window window = CmsBasicDialog.prepareWindow(DialogWidth.wide);
CmsUserInfoDialog dialog = new CmsUserInfoDialog(session, new Runnable() {
public void run() {
window.close();
}
});
window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_MESSAGES_SHOW_USER_0));
window.setContent(dialog);
A_CmsUI.get().addWindow(window);
} | java | {
"resource": ""
} |
q1832 | CmsSliderMap.onBrowserEvent | train | @Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEUP:
Event.releaseCapture(m_slider.getElement());
m_capturedMouse = false;
break;
case Event.ONMOUSEDOWN:
Event.setCapture(m_slider.getElement());
m_capturedMouse = true;
//$FALL-THROUGH$
case Event.ONMOUSEMOVE:
if (m_capturedMouse) {
event.preventDefault();
float x = ((event.getClientX() - (m_colorUnderlay.getAbsoluteLeft())) + Window.getScrollLeft());
float y = ((event.getClientY() - (m_colorUnderlay.getAbsoluteTop())) + Window.getScrollTop());
if (m_parent != null) {
m_parent.onMapSelected(x, y);
}
setSliderPosition(x, y);
}
//$FALL-THROUGH$
default:
}
} | java | {
"resource": ""
} |
q1833 | CmsOuTree.addChildrenForGroupsNode | train | private void addChildrenForGroupsNode(I_CmsOuTreeType type, String ouItem) {
try {
// Cut of type-specific prefix from ouItem with substring()
List<CmsGroup> groups = m_app.readGroupsForOu(m_cms, ouItem.substring(1), type, false);
for (CmsGroup group : groups) {
Pair<String, CmsUUID> key = Pair.of(type.getId(), group.getId());
Item groupItem = m_treeContainer.addItem(key);
if (groupItem == null) {
groupItem = getItem(key);
}
groupItem.getItemProperty(PROP_SID).setValue(group.getId());
groupItem.getItemProperty(PROP_NAME).setValue(getIconCaptionHTML(group, CmsOuTreeType.GROUP));
groupItem.getItemProperty(PROP_TYPE).setValue(type);
setChildrenAllowed(key, false);
m_treeContainer.setParent(key, ouItem);
}
} catch (CmsException e) {
LOG.error("Can not read group", e);
}
} | java | {
"resource": ""
} |
q1834 | CmsOuTree.addChildrenForRolesNode | train | private void addChildrenForRolesNode(String ouItem) {
try {
List<CmsRole> roles = OpenCms.getRoleManager().getRoles(m_cms, ouItem.substring(1), false);
CmsRole.applySystemRoleOrder(roles);
for (CmsRole role : roles) {
String roleId = ouItem + "/" + role.getId();
Item roleItem = m_treeContainer.addItem(roleId);
if (roleItem == null) {
roleItem = getItem(roleId);
}
roleItem.getItemProperty(PROP_NAME).setValue(getIconCaptionHTML(role, CmsOuTreeType.ROLE));
roleItem.getItemProperty(PROP_TYPE).setValue(CmsOuTreeType.ROLE);
setChildrenAllowed(roleId, false);
m_treeContainer.setParent(roleId, ouItem);
}
} catch (CmsException e) {
LOG.error("Can not read group", e);
}
} | java | {
"resource": ""
} |
q1835 | CmsTemplateMappingContentRewriter.checkConfiguredInModules | train | public static boolean checkConfiguredInModules() {
Boolean result = m_moduleCheckCache.get();
if (result == null) {
result = Boolean.valueOf(getConfiguredTemplateMapping() != null);
m_moduleCheckCache.set(result);
}
return result.booleanValue();
} | java | {
"resource": ""
} |
q1836 | CmsScrollPositionCss.addTo | train | @SuppressWarnings("unused")
public static void addTo(
AbstractSingleComponentContainer componentContainer,
int scrollBarrier,
int barrierMargin,
String styleName) {
new CmsScrollPositionCss(componentContainer, scrollBarrier, barrierMargin, styleName);
} | java | {
"resource": ""
} |
q1837 | CmsColorPicker.checkvalue | train | protected boolean checkvalue(String colorvalue) {
boolean valid = validateColorValue(colorvalue);
if (valid) {
if (colorvalue.length() == 4) {
char[] chr = colorvalue.toCharArray();
for (int i = 1; i < 4; i++) {
String foo = String.valueOf(chr[i]);
colorvalue = colorvalue.replaceFirst(foo, foo + foo);
}
}
m_textboxColorValue.setValue(colorvalue, true);
m_colorField.getElement().getStyle().setBackgroundColor(colorvalue);
m_colorValue = colorvalue;
}
return valid;
} | java | {
"resource": ""
} |
q1838 | CmsCmisResourceHelper.collectAllowableActions | train | protected AllowableActions collectAllowableActions(CmsObject cms, CmsResource file) {
try {
if (file == null) {
throw new IllegalArgumentException("File must not be null!");
}
CmsLock lock = cms.getLock(file);
CmsUser user = cms.getRequestContext().getCurrentUser();
boolean canWrite = !cms.getRequestContext().getCurrentProject().isOnlineProject()
&& (lock.isOwnedBy(user) || lock.isLockableBy(user))
&& cms.hasPermissions(file, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.DEFAULT);
boolean isReadOnly = !canWrite;
boolean isFolder = file.isFolder();
boolean isRoot = file.getRootPath().length() <= 1;
Set<Action> aas = new LinkedHashSet<Action>();
addAction(aas, Action.CAN_GET_OBJECT_PARENTS, !isRoot);
addAction(aas, Action.CAN_GET_PROPERTIES, true);
addAction(aas, Action.CAN_UPDATE_PROPERTIES, !isReadOnly);
addAction(aas, Action.CAN_MOVE_OBJECT, !isReadOnly && !isRoot);
addAction(aas, Action.CAN_DELETE_OBJECT, !isReadOnly && !isRoot);
if (isFolder) {
addAction(aas, Action.CAN_GET_DESCENDANTS, true);
addAction(aas, Action.CAN_GET_CHILDREN, true);
addAction(aas, Action.CAN_GET_FOLDER_PARENT, !isRoot);
addAction(aas, Action.CAN_GET_FOLDER_TREE, true);
addAction(aas, Action.CAN_CREATE_DOCUMENT, !isReadOnly);
addAction(aas, Action.CAN_CREATE_FOLDER, !isReadOnly);
addAction(aas, Action.CAN_DELETE_TREE, !isReadOnly);
} else {
addAction(aas, Action.CAN_GET_CONTENT_STREAM, true);
addAction(aas, Action.CAN_SET_CONTENT_STREAM, !isReadOnly);
addAction(aas, Action.CAN_GET_ALL_VERSIONS, true);
}
AllowableActionsImpl result = new AllowableActionsImpl();
result.setAllowableActions(aas);
return result;
} catch (CmsException e) {
handleCmsException(e);
return null;
}
} | java | {
"resource": ""
} |
q1839 | CmsWebdavStatus.getStatusText | train | public static String getStatusText(int nHttpStatusCode) {
Integer intKey = new Integer(nHttpStatusCode);
if (!mapStatusCodes.containsKey(intKey)) {
return "";
} else {
return mapStatusCodes.get(intKey);
}
} | java | {
"resource": ""
} |
q1840 | CmsCmisTypeManager.addType | train | private boolean addType(TypeDefinition type) {
if (type == null) {
return false;
}
if (type.getBaseTypeId() == null) {
return false;
}
// find base type
TypeDefinition baseType = null;
if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) {
baseType = copyTypeDefintion(m_types.get(DOCUMENT_TYPE_ID).getTypeDefinition());
} else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
baseType = copyTypeDefintion(m_types.get(FOLDER_TYPE_ID).getTypeDefinition());
} else if (type.getBaseTypeId() == BaseTypeId.CMIS_RELATIONSHIP) {
baseType = copyTypeDefintion(m_types.get(RELATIONSHIP_TYPE_ID).getTypeDefinition());
} else if (type.getBaseTypeId() == BaseTypeId.CMIS_POLICY) {
baseType = copyTypeDefintion(m_types.get(POLICY_TYPE_ID).getTypeDefinition());
} else {
return false;
}
AbstractTypeDefinition newType = (AbstractTypeDefinition)copyTypeDefintion(type);
// copy property definition
for (PropertyDefinition<?> propDef : baseType.getPropertyDefinitions().values()) {
((AbstractPropertyDefinition<?>)propDef).setIsInherited(Boolean.TRUE);
newType.addPropertyDefinition(propDef);
}
// add it
addTypeInternal(newType);
return true;
} | java | {
"resource": ""
} |
q1841 | CmsSecure.buildRadio | train | public String buildRadio(String propName) throws CmsException {
String propVal = readProperty(propName);
StringBuffer result = new StringBuffer("<table border=\"0\"><tr>");
result.append("<td><input type=\"radio\" value=\"true\" onClick=\"checkNoIntern()\" name=\"").append(
propName).append("\" ").append(Boolean.valueOf(propVal).booleanValue() ? "checked=\"checked\"" : "").append(
"/></td><td id=\"tablelabel\">").append(key(Messages.GUI_LABEL_TRUE_0)).append("</td>");
result.append("<td><input type=\"radio\" value=\"false\" onClick=\"checkNoIntern()\" name=\"").append(
propName).append("\" ").append(Boolean.valueOf(propVal).booleanValue() ? "" : "checked=\"checked\"").append(
"/></td><td id=\"tablelabel\">").append(key(Messages.GUI_LABEL_FALSE_0)).append("</td>");
result.append("<td><input type=\"radio\" value=\"\" onClick=\"checkNoIntern()\" name=\"").append(
propName).append("\" ").append(CmsStringUtil.isEmpty(propVal) ? "checked=\"checked\"" : "").append(
"/></td><td id=\"tablelabel\">").append(getPropertyInheritanceInfo(propName)).append(
"</td></tr></table>");
return result.toString();
} | java | {
"resource": ""
} |
q1842 | CmsWorkplaceManager.setCategoryDisplayOptions | train | public void setCategoryDisplayOptions(
String displayCategoriesByRepository,
String displayCategorySelectionCollapsed) {
m_displayCategoriesByRepository = Boolean.parseBoolean(displayCategoriesByRepository);
m_displayCategorySelectionCollapsed = Boolean.parseBoolean(displayCategorySelectionCollapsed);
} | java | {
"resource": ""
} |
q1843 | A_CmsSerialDateBean.showMoreEntries | train | protected boolean showMoreEntries(Calendar nextDate, int previousOccurrences) {
switch (getSerialEndType()) {
case DATE:
boolean moreByDate = nextDate.getTimeInMillis() < m_endMillis;
boolean moreByOccurrences = previousOccurrences < CmsSerialDateUtil.getMaxEvents();
if (moreByDate && !moreByOccurrences) {
m_hasTooManyOccurrences = Boolean.TRUE;
}
return moreByDate && moreByOccurrences;
case TIMES:
case SINGLE:
return previousOccurrences < getOccurrences();
default:
throw new IllegalArgumentException();
}
} | java | {
"resource": ""
} |
q1844 | A_CmsSerialDateBean.calculateDates | train | private SortedSet<Date> calculateDates() {
if (null == m_allDates) {
SortedSet<Date> result = new TreeSet<>();
if (isAnyDatePossible()) {
Calendar date = getFirstDate();
int previousOccurrences = 0;
while (showMoreEntries(date, previousOccurrences)) {
result.add(date.getTime());
toNextDate(date);
previousOccurrences++;
}
}
m_allDates = result;
}
return m_allDates;
} | java | {
"resource": ""
} |
q1845 | A_CmsSerialDateBean.filterExceptions | train | private SortedSet<Date> filterExceptions(SortedSet<Date> dates) {
SortedSet<Date> result = new TreeSet<Date>();
for (Date d : dates) {
if (!m_exceptions.contains(d)) {
result.add(d);
}
}
return result;
} | java | {
"resource": ""
} |
q1846 | CmsFlexResponse.setHeaderList | train | private void setHeaderList(Map<String, List<String>> headers, String name, String value) {
List<String> values = new ArrayList<String>();
values.add(SET_HEADER + value);
headers.put(name, values);
} | java | {
"resource": ""
} |
q1847 | CmsStringUtil.changeFileNameSuffixTo | train | public static String changeFileNameSuffixTo(String filename, String suffix) {
int dotPos = filename.lastIndexOf('.');
if (dotPos != -1) {
return filename.substring(0, dotPos + 1) + suffix;
} else {
// the string has no suffix
return filename;
}
} | java | {
"resource": ""
} |
q1848 | CmsStringUtil.parseDuration | train | public static final long parseDuration(String durationStr, long defaultValue) {
durationStr = durationStr.toLowerCase().trim();
Matcher matcher = DURATION_NUMBER_AND_UNIT_PATTERN.matcher(durationStr);
long millis = 0;
boolean matched = false;
while (matcher.find()) {
long number = Long.valueOf(matcher.group(1)).longValue();
String unit = matcher.group(2);
long multiplier = 0;
for (int j = 0; j < DURATION_UNTIS.length; j++) {
if (unit.equals(DURATION_UNTIS[j])) {
multiplier = DURATION_MULTIPLIERS[j];
break;
}
}
if (multiplier == 0) {
LOG.warn("parseDuration: Unknown unit " + unit);
} else {
matched = true;
}
millis += number * multiplier;
}
if (!matched) {
millis = defaultValue;
}
return millis;
} | java | {
"resource": ""
} |
q1849 | CmsStringUtil.readStringTemplateGroup | train | public static StringTemplateGroup readStringTemplateGroup(InputStream stream) {
try {
return new StringTemplateGroup(
new InputStreamReader(stream, "UTF-8"),
DefaultTemplateLexer.class,
new StringTemplateErrorListener() {
@SuppressWarnings("synthetic-access")
public void error(String arg0, Throwable arg1) {
LOG.error(arg0 + ": " + arg1.getMessage(), arg1);
}
@SuppressWarnings("synthetic-access")
public void warning(String arg0) {
LOG.warn(arg0);
}
});
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
return new StringTemplateGroup("dummy");
}
} | java | {
"resource": ""
} |
q1850 | CmsDateBoxEvent.fire | train | public static void fire(I_CmsHasDateBoxEventHandlers source, Date date, boolean isTyping) {
if (TYPE != null) {
CmsDateBoxEvent event = new CmsDateBoxEvent(date, isTyping);
source.fireEvent(event);
}
} | java | {
"resource": ""
} |
q1851 | CmsModuleUpdater.createAndSetModuleImportProject | train | protected CmsProject createAndSetModuleImportProject(CmsObject cms, CmsModule module) throws CmsException {
CmsProject importProject = cms.createProject(
org.opencms.module.Messages.get().getBundle(cms.getRequestContext().getLocale()).key(
org.opencms.module.Messages.GUI_IMPORT_MODULE_PROJECT_NAME_1,
new Object[] {module.getName()}),
org.opencms.module.Messages.get().getBundle(cms.getRequestContext().getLocale()).key(
org.opencms.module.Messages.GUI_IMPORT_MODULE_PROJECT_DESC_1,
new Object[] {module.getName()}),
OpenCms.getDefaultUsers().getGroupAdministrators(),
OpenCms.getDefaultUsers().getGroupAdministrators(),
CmsProject.PROJECT_TYPE_TEMPORARY);
cms.getRequestContext().setCurrentProject(importProject);
cms.copyResourceToProject("/");
return importProject;
} | java | {
"resource": ""
} |
q1852 | CmsModuleUpdater.deleteConflictingResources | train | protected void deleteConflictingResources(CmsObject cms, CmsModule module, Map<CmsUUID, CmsUUID> conflictingIds)
throws CmsException, Exception {
CmsProject conflictProject = cms.createProject(
"Deletion of conflicting resources for " + module.getName(),
"Deletion of conflicting resources for " + module.getName(),
OpenCms.getDefaultUsers().getGroupAdministrators(),
OpenCms.getDefaultUsers().getGroupAdministrators(),
CmsProject.PROJECT_TYPE_TEMPORARY);
CmsObject deleteCms = OpenCms.initCmsObject(cms);
deleteCms.getRequestContext().setCurrentProject(conflictProject);
for (CmsUUID vfsId : conflictingIds.values()) {
CmsResource toDelete = deleteCms.readResource(vfsId, CmsResourceFilter.ALL);
lock(deleteCms, toDelete);
deleteCms.deleteResource(toDelete, CmsResource.DELETE_PRESERVE_SIBLINGS);
}
OpenCms.getPublishManager().publishProject(deleteCms);
OpenCms.getPublishManager().waitWhileRunning();
} | java | {
"resource": ""
} |
q1853 | CmsModuleUpdater.parseLinks | train | protected void parseLinks(CmsObject cms) throws CmsException {
List<CmsResource> linkParseables = new ArrayList<>();
for (CmsResourceImportData resData : m_moduleData.getResourceData()) {
CmsResource importRes = resData.getImportResource();
if ((importRes != null) && m_importIds.contains(importRes.getStructureId()) && isLinkParsable(importRes)) {
linkParseables.add(importRes);
}
}
m_report.println(Messages.get().container(Messages.RPT_START_PARSE_LINKS_0), I_CmsReport.FORMAT_HEADLINE);
CmsImportVersion10.parseLinks(cms, linkParseables, m_report);
m_report.println(Messages.get().container(Messages.RPT_END_PARSE_LINKS_0), I_CmsReport.FORMAT_HEADLINE);
} | java | {
"resource": ""
} |
q1854 | CmsModuleUpdater.processDeletions | train | protected void processDeletions(CmsObject cms, List<CmsResource> toDelete) throws CmsException {
Collections.sort(toDelete, (a, b) -> b.getRootPath().compareTo(a.getRootPath()));
for (CmsResource deleteRes : toDelete) {
m_report.print(
org.opencms.importexport.Messages.get().container(org.opencms.importexport.Messages.RPT_DELFOLDER_0),
I_CmsReport.FORMAT_NOTE);
m_report.print(
org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_ARGUMENT_1,
deleteRes.getRootPath()));
CmsLock lock = cms.getLock(deleteRes);
if (lock.isUnlocked()) {
lock(cms, deleteRes);
}
cms.deleteResource(deleteRes, CmsResource.DELETE_PRESERVE_SIBLINGS);
m_report.println(
org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
I_CmsReport.FORMAT_OK);
}
} | java | {
"resource": ""
} |
q1855 | CmsModuleUpdater.runImportScript | train | protected void runImportScript(CmsObject cms, CmsModule module) {
LOG.info("Executing import script for module " + module.getName());
m_report.println(
org.opencms.module.Messages.get().container(org.opencms.module.Messages.RPT_IMPORT_SCRIPT_HEADER_0),
I_CmsReport.FORMAT_HEADLINE);
String importScript = "echo on\n" + module.getImportScript();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
PrintStream out = new PrintStream(buffer);
CmsShell shell = new CmsShell(cms, "${user}@${project}:${siteroot}|${uri}>", null, out, out);
shell.execute(importScript);
String outputString = buffer.toString();
LOG.info("Shell output for import script was: \n" + outputString);
m_report.println(
org.opencms.module.Messages.get().container(
org.opencms.module.Messages.RPT_IMPORT_SCRIPT_OUTPUT_1,
outputString));
} | java | {
"resource": ""
} |
q1856 | CmsJspVfsAccessBean.getAvailableLocales | train | public Map<String, List<Locale>> getAvailableLocales() {
if (m_availableLocales == null) {
// create lazy map only on demand
m_availableLocales = CmsCollectionsGenericWrapper.createLazyMap(new CmsAvailableLocaleLoaderTransformer());
}
return m_availableLocales;
} | java | {
"resource": ""
} |
q1857 | CmsModule.adjustSiteRootIfNecessary | train | private static CmsObject adjustSiteRootIfNecessary(final CmsObject cms, final CmsModule module)
throws CmsException {
CmsObject cmsClone;
if ((null == module.getSite()) || cms.getRequestContext().getSiteRoot().equals(module.getSite())) {
cmsClone = cms;
} else {
cmsClone = OpenCms.initCmsObject(cms);
cmsClone.getRequestContext().setSiteRoot(module.getSite());
}
return cmsClone;
} | java | {
"resource": ""
} |
q1858 | CmsModule.shouldIncrementVersionBasedOnResources | train | public boolean shouldIncrementVersionBasedOnResources(CmsObject cms) throws CmsException {
if (m_checkpointTime == 0) {
return true;
}
// adjust the site root, if necessary
CmsObject cmsClone = adjustSiteRootIfNecessary(cms, this);
// calculate the module resources
List<CmsResource> moduleResources = calculateModuleResources(cmsClone, this);
for (CmsResource resource : moduleResources) {
try {
List<CmsResource> resourcesToCheck = Lists.newArrayList();
resourcesToCheck.add(resource);
if (resource.isFolder()) {
resourcesToCheck.addAll(cms.readResources(resource, CmsResourceFilter.IGNORE_EXPIRATION, true));
}
for (CmsResource resourceToCheck : resourcesToCheck) {
if (resourceToCheck.getDateLastModified() > m_checkpointTime) {
return true;
}
}
} catch (CmsException e) {
LOG.warn(e.getLocalizedMessage(), e);
continue;
}
}
return false;
} | java | {
"resource": ""
} |
q1859 | CmsSqlConsoleResults.getColumnType | train | public Class<?> getColumnType(int c) {
for (int r = 0; r < m_data.size(); r++) {
Object val = m_data.get(r).get(c);
if (val != null) {
return val.getClass();
}
}
return Object.class;
} | java | {
"resource": ""
} |
q1860 | CmsSqlConsoleResults.getCsv | train | public String getCsv() {
StringWriter writer = new StringWriter();
try (CSVWriter csv = new CSVWriter(writer)) {
List<String> headers = new ArrayList<>();
for (String col : m_columns) {
headers.add(col);
}
csv.writeNext(headers.toArray(new String[] {}));
for (List<Object> row : m_data) {
List<String> colCsv = new ArrayList<>();
for (Object col : row) {
colCsv.add(String.valueOf(col));
}
csv.writeNext(colCsv.toArray(new String[] {}));
}
return writer.toString();
} catch (IOException e) {
return null;
}
} | java | {
"resource": ""
} |
q1861 | CmsContainerConfigurationCacheState.getBasePath | train | protected String getBasePath(String rootPath) {
if (rootPath.endsWith(INHERITANCE_CONFIG_FILE_NAME)) {
return rootPath.substring(0, rootPath.length() - INHERITANCE_CONFIG_FILE_NAME.length());
}
return rootPath;
} | java | {
"resource": ""
} |
q1862 | CmsWidgetUtil.getStringOption | train | public static String getStringOption(Map<String, String> configOptions, String optionKey, String defaultValue) {
String result = configOptions.get(optionKey);
return null != result ? result : defaultValue;
} | java | {
"resource": ""
} |
q1863 | CmsMultiSelectWidget.generateValue | train | private String generateValue() {
String result = "";
for (CmsCheckBox checkbox : m_checkboxes) {
if (checkbox.isChecked()) {
result += checkbox.getInternalValue() + ",";
}
}
if (result.contains(",")) {
result = result.substring(0, result.lastIndexOf(","));
}
return result;
} | java | {
"resource": ""
} |
q1864 | CmsSqlConsoleLayout.runQuery | train | protected void runQuery() {
String pool = m_pool.getValue();
String stmt = m_script.getValue();
if (stmt.trim().isEmpty()) {
return;
}
CmsStringBufferReport report = new CmsStringBufferReport(Locale.ENGLISH);
List<Throwable> errors = new ArrayList<>();
CmsSqlConsoleResults result = m_console.execute(stmt, pool, report, errors);
if (errors.size() > 0) {
CmsErrorDialog.showErrorDialog(report.toString() + errors.get(0).getMessage(), errors.get(0));
} else {
Window window = CmsBasicDialog.prepareWindow(DialogWidth.max);
window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_SQLCONSOLE_QUERY_RESULTS_0));
window.setContent(new CmsSqlConsoleResultsForm(result, report.toString()));
A_CmsUI.get().addWindow(window);
window.center();
}
} | java | {
"resource": ""
} |
q1865 | CmsSetupUI.getSetupPage | train | public static Resource getSetupPage(I_SetupUiContext context, String name) {
String path = CmsStringUtil.joinPaths(context.getSetupBean().getContextPath(), CmsSetupBean.FOLDER_SETUP, name);
Resource resource = new ExternalResource(path);
return resource;
} | java | {
"resource": ""
} |
q1866 | CmsSetupUI.showStep | train | protected void showStep(A_CmsSetupStep step) {
Window window = newWindow();
window.setContent(step);
window.setCaption(step.getTitle());
A_CmsUI.get().addWindow(window);
window.center();
} | java | {
"resource": ""
} |
q1867 | CmsSetupUI.updateStep | train | protected void updateStep(int stepNo) {
if ((0 <= stepNo) && (stepNo < m_steps.size())) {
Class<? extends A_CmsSetupStep> cls = m_steps.get(stepNo);
A_CmsSetupStep step;
try {
step = cls.getConstructor(I_SetupUiContext.class).newInstance(this);
showStep(step);
m_stepNo = stepNo; // Only update step number if no exceptions
} catch (Exception e) {
CmsSetupErrorDialog.showErrorDialog(e);
}
}
} | java | {
"resource": ""
} |
q1868 | CmsSearchControllerFacetField.appendFacetOption | train | protected void appendFacetOption(StringBuffer query, final String name, final String value) {
query.append(" facet.").append(name).append("=").append(value);
} | java | {
"resource": ""
} |
q1869 | CmsMessageBundleEditorOptions.setEditedFilePath | train | public void setEditedFilePath(final String editedFilePath) {
m_filePathField.setReadOnly(false);
m_filePathField.setValue(editedFilePath);
m_filePathField.setReadOnly(true);
} | java | {
"resource": ""
} |
q1870 | CmsMessageBundleEditorOptions.updateShownOptions | train | public void updateShownOptions(boolean showModeSwitch, boolean showAddKeyOption) {
if (showModeSwitch != m_showModeSwitch) {
m_upperLeftComponent.removeAllComponents();
m_upperLeftComponent.addComponent(m_languageSwitch);
if (showModeSwitch) {
m_upperLeftComponent.addComponent(m_modeSwitch);
}
m_upperLeftComponent.addComponent(m_filePathLabel);
m_showModeSwitch = showModeSwitch;
}
if (showAddKeyOption != m_showAddKeyOption) {
if (showAddKeyOption) {
m_optionsComponent.addComponent(m_lowerLeftComponent, 0, 1);
m_optionsComponent.addComponent(m_lowerRightComponent, 1, 1);
} else {
m_optionsComponent.removeComponent(0, 1);
m_optionsComponent.removeComponent(1, 1);
}
m_showAddKeyOption = showAddKeyOption;
}
} | java | {
"resource": ""
} |
q1871 | CmsMessageBundleEditorOptions.handleAddKey | train | void handleAddKey() {
String key = m_addKeyInput.getValue();
if (m_listener.handleAddKey(key)) {
Notification.show(
key.isEmpty()
? m_messages.key(Messages.GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_EMPTY_KEY_SUCCESSFULLY_ADDED_0)
: m_messages.key(Messages.GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_KEY_SUCCESSFULLY_ADDED_1, key));
} else {
CmsMessageBundleEditorTypes.showWarning(
m_messages.key(Messages.GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_KEY_ALREADEY_EXISTS_CAPTION_0),
m_messages.key(Messages.GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_KEY_ALREADEY_EXISTS_DESCRIPTION_1, key));
}
m_addKeyInput.focus();
m_addKeyInput.selectAll();
} | java | {
"resource": ""
} |
q1872 | CmsMessageBundleEditorOptions.setLanguage | train | void setLanguage(final Locale locale) {
if (!m_languageSelect.getValue().equals(locale)) {
m_languageSelect.setValue(locale);
}
} | java | {
"resource": ""
} |
q1873 | CmsMessageBundleEditorOptions.createAddKeyButton | train | private Component createAddKeyButton() {
// the "+" button
Button addKeyButton = new Button();
addKeyButton.addStyleName("icon-only");
addKeyButton.addStyleName("borderless-colored");
addKeyButton.setDescription(m_messages.key(Messages.GUI_ADD_KEY_0));
addKeyButton.setIcon(FontOpenCms.CIRCLE_PLUS, m_messages.key(Messages.GUI_ADD_KEY_0));
addKeyButton.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
handleAddKey();
}
});
return addKeyButton;
} | java | {
"resource": ""
} |
q1874 | CmsMessageBundleEditorOptions.initModeSwitch | train | private void initModeSwitch(final EditMode current) {
FormLayout modes = new FormLayout();
modes.setHeight("100%");
modes.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
m_modeSelect = new ComboBox();
m_modeSelect.setCaption(m_messages.key(Messages.GUI_VIEW_SWITCHER_LABEL_0));
// add Modes
m_modeSelect.addItem(CmsMessageBundleEditorTypes.EditMode.DEFAULT);
m_modeSelect.setItemCaption(
CmsMessageBundleEditorTypes.EditMode.DEFAULT,
m_messages.key(Messages.GUI_VIEW_SWITCHER_EDITMODE_DEFAULT_0));
m_modeSelect.addItem(CmsMessageBundleEditorTypes.EditMode.MASTER);
m_modeSelect.setItemCaption(
CmsMessageBundleEditorTypes.EditMode.MASTER,
m_messages.key(Messages.GUI_VIEW_SWITCHER_EDITMODE_MASTER_0));
// set current mode as selected
m_modeSelect.setValue(current);
m_modeSelect.setNewItemsAllowed(false);
m_modeSelect.setTextInputAllowed(false);
m_modeSelect.setNullSelectionAllowed(false);
m_modeSelect.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
public void valueChange(ValueChangeEvent event) {
m_listener.handleModeChange((EditMode)event.getProperty().getValue());
}
});
modes.addComponent(m_modeSelect);
m_modeSwitch = modes;
} | java | {
"resource": ""
} |
q1875 | CmsMessageBundleEditorOptions.initUpperLeftComponent | train | private void initUpperLeftComponent() {
m_upperLeftComponent = new HorizontalLayout();
m_upperLeftComponent.setHeight("100%");
m_upperLeftComponent.setSpacing(true);
m_upperLeftComponent.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT);
m_upperLeftComponent.addComponent(m_languageSwitch);
m_upperLeftComponent.addComponent(m_filePathLabel);
} | java | {
"resource": ""
} |
q1876 | CmsScheduleManager.getJob | train | public CmsScheduledJobInfo getJob(String id) {
Iterator<CmsScheduledJobInfo> it = m_jobs.iterator();
while (it.hasNext()) {
CmsScheduledJobInfo job = it.next();
if (job.getId().equals(id)) {
return job;
}
}
// not found
return null;
} | java | {
"resource": ""
} |
q1877 | CmsPatternPanelYearlyView.onMonthChange | train | @UiHandler({"m_atMonth", "m_everyMonth"})
void onMonthChange(ValueChangeEvent<String> event) {
if (handleChange()) {
m_controller.setMonth(event.getValue());
}
} | java | {
"resource": ""
} |
q1878 | CmsPatternPanelYearlyView.onWeekOfMonthChange | train | @UiHandler("m_atNumber")
void onWeekOfMonthChange(ValueChangeEvent<String> event) {
if (handleChange()) {
m_controller.setWeekOfMonth(event.getValue());
}
} | java | {
"resource": ""
} |
q1879 | CmsResourceBuilder.buildResource | train | public CmsResource buildResource() {
return new CmsResource(
m_structureId,
m_resourceId,
m_rootPath,
m_type,
m_flags,
m_projectLastModified,
m_state,
m_dateCreated,
m_userCreated,
m_dateLastModified,
m_userLastModified,
m_dateReleased,
m_dateExpired,
m_length,
m_flags,
m_dateContent,
m_version);
} | java | {
"resource": ""
} |
q1880 | CmsOrgUnitManager.getAllAccessibleProjects | train | public List<CmsProject> getAllAccessibleProjects(CmsObject cms, String ouFqn, boolean includeSubOus)
throws CmsException {
CmsOrganizationalUnit orgUnit = readOrganizationalUnit(cms, ouFqn);
return (m_securityManager.getAllAccessibleProjects(cms.getRequestContext(), orgUnit, includeSubOus));
} | java | {
"resource": ""
} |
q1881 | CmsJspContentAccessValueWrapper.getToDateSeries | train | public CmsJspDateSeriesBean getToDateSeries() {
if (m_dateSeries == null) {
m_dateSeries = new CmsJspDateSeriesBean(this, m_cms.getRequestContext().getLocale());
}
return m_dateSeries;
} | java | {
"resource": ""
} |
q1882 | CmsContainerPageCopier.copyPageOnly | train | public void copyPageOnly(CmsResource originalPage, String targetPageRootPath)
throws CmsException, NoCustomReplacementException {
if ((null == originalPage)
|| !OpenCms.getResourceManager().getResourceType(originalPage).getTypeName().equals(
CmsResourceTypeXmlContainerPage.getStaticTypeName())) {
throw new CmsException(new CmsMessageContainer(Messages.get(), Messages.ERR_PAGECOPY_INVALID_PAGE_0));
}
m_originalPage = originalPage;
CmsObject rootCms = getRootCms();
rootCms.copyResource(originalPage.getRootPath(), targetPageRootPath);
CmsResource copiedPage = rootCms.readResource(targetPageRootPath, CmsResourceFilter.IGNORE_EXPIRATION);
m_targetFolder = rootCms.readResource(CmsResource.getFolderPath(copiedPage.getRootPath()));
replaceElements(copiedPage);
attachLocaleGroups(copiedPage);
tryUnlock(copiedPage);
} | java | {
"resource": ""
} |
q1883 | CmsContainerPageCopier.attachLocaleGroups | train | private void attachLocaleGroups(CmsResource copiedPage) throws CmsException {
CmsLocaleGroupService localeGroupService = getRootCms().getLocaleGroupService();
if (Status.linkable == localeGroupService.checkLinkable(m_originalPage, copiedPage)) {
try {
localeGroupService.attachLocaleGroupIndirect(m_originalPage, copiedPage);
} catch (CmsException e) {
LOG.error(e.getLocalizedMessage(), e);
}
}
} | java | {
"resource": ""
} |
q1884 | CmsUndeleteDialog.undelete | train | protected List<CmsUUID> undelete() throws CmsException {
List<CmsUUID> modifiedResources = new ArrayList<CmsUUID>();
CmsObject cms = m_context.getCms();
for (CmsResource resource : m_context.getResources()) {
CmsLockActionRecord actionRecord = null;
try {
actionRecord = CmsLockUtil.ensureLock(m_context.getCms(), resource);
cms.undeleteResource(cms.getSitePath(resource), true);
modifiedResources.add(resource.getStructureId());
} finally {
if ((actionRecord != null) && (actionRecord.getChange() == LockChange.locked)) {
try {
cms.unlockResource(resource);
} catch (CmsLockException e) {
LOG.warn(e.getLocalizedMessage(), e);
}
}
}
}
return modifiedResources;
} | java | {
"resource": ""
} |
q1885 | CmsImportExportUserDialog.importUserFromFile | train | protected void importUserFromFile() {
CmsImportUserThread thread = new CmsImportUserThread(
m_cms,
m_ou,
m_userImportList,
getGroupsList(m_importGroups, true),
getRolesList(m_importRoles, true),
m_sendMail.getValue().booleanValue());
thread.start();
CmsShowReportDialog dialog = new CmsShowReportDialog(thread, new Runnable() {
public void run() {
m_window.close();
}
});
m_window.setContent(dialog);
} | java | {
"resource": ""
} |
q1886 | CmsSerialDateBeanMonthlyWeeks.toCorrectDateWithDay | train | private void toCorrectDateWithDay(Calendar date, WeekOfMonth week) {
date.set(Calendar.DAY_OF_MONTH, 1);
int daysToFirstWeekDayMatch = ((m_weekDay.toInt() + I_CmsSerialDateValue.NUM_OF_WEEKDAYS)
- (date.get(Calendar.DAY_OF_WEEK))) % I_CmsSerialDateValue.NUM_OF_WEEKDAYS;
date.add(Calendar.DAY_OF_MONTH, daysToFirstWeekDayMatch);
int wouldBeDayOfMonth = date.get(Calendar.DAY_OF_MONTH)
+ ((week.ordinal()) * I_CmsSerialDateValue.NUM_OF_WEEKDAYS);
if (wouldBeDayOfMonth > date.getActualMaximum(Calendar.DAY_OF_MONTH)) {
date.set(Calendar.DAY_OF_MONTH, wouldBeDayOfMonth - I_CmsSerialDateValue.NUM_OF_WEEKDAYS);
} else {
date.set(Calendar.DAY_OF_MONTH, wouldBeDayOfMonth);
}
} | java | {
"resource": ""
} |
q1887 | CmsSerialDateBeanMonthlyWeeks.toNextDate | train | private void toNextDate(Calendar date, int interval) {
long previousDate = date.getTimeInMillis();
if (!m_weekOfMonthIterator.hasNext()) {
date.add(Calendar.MONTH, interval);
m_weekOfMonthIterator = m_weeksOfMonth.iterator();
}
toCorrectDateWithDay(date, m_weekOfMonthIterator.next());
if (previousDate == date.getTimeInMillis()) { // this can happen if the fourth and the last week are checked.
toNextDate(date);
}
} | java | {
"resource": ""
} |
q1888 | CmsResourceTypeApp.isResourceTypeIdFree | train | public static boolean isResourceTypeIdFree(int id) {
try {
OpenCms.getResourceManager().getResourceType(id);
} catch (CmsLoaderException e) {
return true;
}
return false;
} | java | {
"resource": ""
} |
q1889 | A_CmsAdeGalleryWidget.getGalleryOpenParams | train | protected Map<String, String> getGalleryOpenParams(
CmsObject cms,
CmsMessages messages,
I_CmsWidgetParameter param,
String resource,
long hashId) {
Map<String, String> result = new HashMap<String, String>();
result.put(I_CmsGalleryProviderConstants.CONFIG_GALLERY_MODE, A_CmsAjaxGallery.MODE_WIDGET);
result.put(I_CmsGalleryProviderConstants.CONFIG_GALLERY_STORAGE_PREFIX, getGalleryStoragePrefix());
result.put(I_CmsGalleryProviderConstants.CONFIG_RESOURCE_TYPES, getGalleryTypes());
if (param.getId() != null) {
result.put(I_CmsGalleryProviderConstants.KEY_FIELD_ID, param.getId());
// use javascript to read the current field value
result.put(
I_CmsGalleryProviderConstants.CONFIG_CURRENT_ELEMENT,
"'+document.getElementById('" + param.getId() + "').getAttribute('value')+'");
}
result.put(I_CmsGalleryProviderConstants.KEY_HASH_ID, "" + hashId);
// the edited resource
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(resource)) {
result.put(I_CmsGalleryProviderConstants.CONFIG_REFERENCE_PATH, resource);
}
// the start up gallery path
CmsGalleryWidgetConfiguration configuration = getWidgetConfiguration(cms, messages, param);
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(configuration.getStartup())) {
result.put(I_CmsGalleryProviderConstants.CONFIG_GALLERY_PATH, configuration.getStartup());
}
// set gallery types if available
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(configuration.getGalleryTypes())) {
result.put(I_CmsGalleryProviderConstants.CONFIG_GALLERY_TYPES, configuration.getGalleryTypes());
}
result.put(I_CmsGalleryProviderConstants.CONFIG_GALLERY_NAME, getGalleryName());
return result;
} | java | {
"resource": ""
} |
q1890 | CmsSolrFieldConfiguration.appendFieldMappingsFromElementsOnThePage | train | protected I_CmsSearchDocument appendFieldMappingsFromElementsOnThePage(
I_CmsSearchDocument document,
CmsObject cms,
CmsResource resource,
List<String> systemFields) {
try {
CmsFile file = cms.readFile(resource);
CmsXmlContainerPage containerPage = CmsXmlContainerPageFactory.unmarshal(cms, file);
CmsContainerPageBean containerBean = containerPage.getContainerPage(cms);
if (containerBean != null) {
for (CmsContainerElementBean element : containerBean.getElements()) {
element.initResource(cms);
CmsResource elemResource = element.getResource();
Set<CmsSearchField> mappedFields = getXSDMappingsForPage(cms, elemResource);
if (mappedFields != null) {
for (CmsSearchField field : mappedFields) {
if (!systemFields.contains(field.getName())) {
document = appendFieldMapping(
document,
field,
cms,
elemResource,
CmsSolrDocumentXmlContent.extractXmlContent(cms, elemResource, getIndex()),
cms.readPropertyObjects(resource, false),
cms.readPropertyObjects(resource, true));
} else {
LOG.error(
Messages.get().getBundle().key(
Messages.LOG_SOLR_ERR_MAPPING_TO_INTERNALLY_USED_FIELD_3,
elemResource.getRootPath(),
field.getName(),
resource.getRootPath()));
}
}
}
}
}
} catch (CmsException e) {
// Should be thrown if element on the page does not exist anymore - this is possible, but not necessarily an error.
// Hence, just notice it in the debug log.
if (LOG.isDebugEnabled()) {
LOG.debug(e.getLocalizedMessage(), e);
}
}
return document;
} | java | {
"resource": ""
} |
q1891 | CmsRootHandler.clearHandlers | train | public void clearHandlers() {
for (Map<String, CmsAttributeHandler> handlers : m_handlers) {
for (CmsAttributeHandler handler : handlers.values()) {
handler.clearHandlers();
}
handlers.clear();
}
m_handlers.clear();
m_handlers.add(new HashMap<String, CmsAttributeHandler>());
m_handlerById.clear();
} | java | {
"resource": ""
} |
q1892 | CmsCheckableDatePanel.setDates | train | public void setDates(SortedSet<Date> dates, boolean checked) {
m_checkBoxes.clear();
for (Date date : dates) {
CmsCheckBox cb = generateCheckBox(date, checked);
m_checkBoxes.add(cb);
}
reInitLayoutElements();
setDatesInternal(dates);
} | java | {
"resource": ""
} |
q1893 | CmsCheckableDatePanel.setDatesWithCheckState | train | public void setDatesWithCheckState(Collection<CmsPair<Date, Boolean>> datesWithCheckInfo) {
SortedSet<Date> dates = new TreeSet<>();
m_checkBoxes.clear();
for (CmsPair<Date, Boolean> p : datesWithCheckInfo) {
addCheckBox(p.getFirst(), p.getSecond().booleanValue());
dates.add(p.getFirst());
}
reInitLayoutElements();
setDatesInternal(dates);
} | java | {
"resource": ""
} |
q1894 | CmsCheckableDatePanel.addCheckBox | train | private void addCheckBox(Date date, boolean checkState) {
CmsCheckBox cb = generateCheckBox(date, checkState);
m_checkBoxes.add(cb);
reInitLayoutElements();
} | java | {
"resource": ""
} |
q1895 | CmsCheckableDatePanel.addDateWithCheckState | train | private void addDateWithCheckState(Date date, boolean checkState) {
addCheckBox(date, checkState);
if (!m_dates.contains(date)) {
m_dates.add(date);
fireValueChange();
}
} | java | {
"resource": ""
} |
q1896 | CmsCheckableDatePanel.generateCheckBox | train | private CmsCheckBox generateCheckBox(Date date, boolean checkState) {
CmsCheckBox cb = new CmsCheckBox();
cb.setText(m_dateFormat.format(date));
cb.setChecked(checkState);
cb.getElement().setPropertyObject("date", date);
return cb;
} | java | {
"resource": ""
} |
q1897 | CmsCheckableDatePanel.reInitLayoutElements | train | private void reInitLayoutElements() {
m_panel.clear();
for (CmsCheckBox cb : m_checkBoxes) {
m_panel.add(setStyle(m_onlyLabels ? new Label(cb.getText()) : cb));
}
} | java | {
"resource": ""
} |
q1898 | CmsCheckableDatePanel.setDatesInternal | train | private void setDatesInternal(SortedSet<Date> dates) {
if (!m_dates.equals(dates)) {
m_dates = new TreeSet<>(dates);
fireValueChange();
}
} | java | {
"resource": ""
} |
q1899 | CmsCheckableDatePanel.setStyle | train | private Widget setStyle(Widget widget) {
widget.setWidth(m_width);
widget.getElement().getStyle().setDisplay(Display.INLINE_BLOCK);
return widget;
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.