map, A key) {
if (map == null) {
return null;
}
return map.get(key);
}
/**
* Adds a new change event handler.
*
* @param handler the handler to add
*
* @return the handler registration
*/
public HandlerRegistration addChangeHandler(I_CmsSitemapChangeHandler handler) {
return m_eventBus.addHandlerToSource(CmsSitemapChangeEvent.getType(), this, handler);
}
/**
* Adds a new detail page information bean.
*
* @param info the detail page information bean to add
*/
public void addDetailPageInfo(CmsDetailPageInfo info) {
m_detailPageTable.add(info);
m_allDetailPageInfos.put(info.getId(), info);
}
/**
* Adds a new load event handler.
*
* @param handler the handler to add
*
* @return the handler registration
*/
public HandlerRegistration addLoadHandler(I_CmsSitemapLoadHandler handler) {
return m_eventBus.addHandlerToSource(CmsSitemapLoadEvent.getType(), this, handler);
}
/**
* Adds a handler for property changes caused by user edits.
*
* @param handler a new handler for property updates caused by the user
*/
public void addPropertyUpdateHandler(I_CmsPropertyUpdateHandler handler) {
m_propertyUpdateHandlers.add(handler);
}
/**
* Adds the entry to the navigation.
*
* @param entry the entry
*/
public void addToNavigation(CmsClientSitemapEntry entry) {
entry.setInNavigation(true);
CmsSitemapChange change = new CmsSitemapChange(entry.getId(), entry.getSitePath(), ChangeType.modify);
CmsPropertyModification mod = new CmsPropertyModification(
entry.getId(),
CmsClientProperty.PROPERTY_NAVTEXT,
entry.getTitle(),
true);
change.setPropertyChanges(Collections.singletonList(mod));
change.setPosition(entry.getPosition());
commitChange(change, null);
}
/**
* Makes the given sitemap entry the default detail page for its detail page type.
*
* @param entry an entry representing a detail page
*/
public void bump(CmsClientSitemapEntry entry) {
CmsDetailPageTable table = getDetailPageTable().copy();
table.bump(entry.getId());
CmsSitemapChange change = new CmsSitemapChange(entry.getId(), entry.getSitePath(), ChangeType.bumpDetailPage);
change.setDetailPageInfos(table.toList());
commitChange(change, null);
}
/**
* Changes the given category.
*
* @param id the category id
* @param title the new category title
* @param name the new category name
*/
public void changeCategory(final CmsUUID id, final String title, final String name) {
CmsRpcAction action = new CmsRpcAction() {
@Override
public void execute() {
start(200, true);
getService().changeCategory(getEntryPoint(), id, title, name, this);
}
@Override
protected void onResponse(Void result) {
stop(false);
loadCategories(true);
}
};
action.execute();
}
/**
* Clears the deleted clip-board list and commits the change.
*/
public void clearDeletedList() {
CmsSitemapClipboardData clipboardData = getData().getClipboardData().copy();
clipboardData.getDeletions().clear();
CmsSitemapChange change = new CmsSitemapChange(null, null, ChangeType.clipboardOnly);
change.setClipBoardData(clipboardData);
commitChange(change, null);
}
/**
* Clears the modified clip-board list and commits the change.
*/
public void clearModifiedList() {
CmsSitemapClipboardData clipboardData = getData().getClipboardData().copy();
clipboardData.getModifications().clear();
CmsSitemapChange change = new CmsSitemapChange(null, null, ChangeType.clipboardOnly);
change.setClipBoardData(clipboardData);
commitChange(change, null);
}
/**
* Registers a new sitemap entry.
*
* @param newEntry the new entry
* @param parentId the parent entry id
* @param resourceTypeId the resource type id
* @param copyResourceId the copy resource id
* @param parameter an additional parameter which may contain more information needed to create the new resource
* @param isNewSitemap a flag controlling whether a new sitemap should be created
*/
public void create(
CmsClientSitemapEntry newEntry,
CmsUUID parentId,
int resourceTypeId,
CmsUUID copyResourceId,
String parameter,
boolean isNewSitemap) {
assert (getEntry(newEntry.getSitePath()) == null);
CmsSitemapChange change = new CmsSitemapChange(null, newEntry.getSitePath(), ChangeType.create);
change.setDefaultFileId(newEntry.getDefaultFileId());
change.setParentId(parentId);
change.setName(newEntry.getName());
change.setPosition(newEntry.getPosition());
change.setOwnInternalProperties(newEntry.getOwnProperties());
change.setDefaultFileInternalProperties(newEntry.getDefaultFileProperties());
change.setTitle(newEntry.getTitle());
change.setCreateParameter(parameter);
change.setNewResourceTypeId(resourceTypeId);
if (isNewSitemap) {
change.setCreateSitemapFolderType(newEntry.getResourceTypeName());
}
change.setNewCopyResourceId(copyResourceId);
if (isDetailPage(newEntry)) {
CmsDetailPageTable table = getDetailPageTable().copy();
if (!table.contains(newEntry.getId())) {
CmsDetailPageInfo info = new CmsDetailPageInfo(
newEntry.getId(),
newEntry.getSitePath(),
newEntry.getDetailpageTypeName());
table.add(info);
}
change.setDetailPageInfos(table.toList());
}
CmsSitemapClipboardData data = getData().getClipboardData().copy();
data.addModified(newEntry);
change.setClipBoardData(data);
commitChange(change, null);
}
/**
* Creates a new category.
*
* @param id the parent category id, or the null uuid for a new top-level category
* @param title the title of the category
* @param name the name of the category
*/
public void createCategory(final CmsUUID id, final String title, final String name) {
CmsRpcAction action = new CmsRpcAction() {
@Override
public void execute() {
start(200, true);
getService().createCategory(getEntryPoint(), id, title, name, this);
}
@Override
protected void onResponse(Void result) {
stop(false);
loadCategories(true);
}
};
action.execute();
}
/**
* Creates a new gallery folder of the given type.
*
* @param parentId the parent folder id
* @param galleryTypeId the folder type id
* @param title the folder title
*/
public void createNewGallery(final CmsUUID parentId, final int galleryTypeId, final String title) {
final String parentFolder = parentId != null
? getEntryById(parentId).getSitePath()
: CmsStringUtil.joinPaths(m_data.getRoot().getSitePath(), m_data.getDefaultGalleryFolder());
CmsRpcAction action = new CmsRpcAction() {
@Override
public void execute() {
getService().createNewGalleryFolder(parentFolder, title, galleryTypeId, this);
}
@Override
protected void onResponse(CmsGalleryFolderEntry result) {
CmsSitemapView.getInstance().displayNewGallery(result);
}
};
action.execute();
}
/**
* Creates a new model page.
*
* @param title the title of the model page
* @param description the description of the model page
* @param copyId the structure id of the resource which should be used as a copy model for the new page
* @param isModelGroup in case of a model group page
*/
public void createNewModelPage(
final String title,
final String description,
final CmsUUID copyId,
final boolean isModelGroup) {
CmsRpcAction action = new CmsRpcAction() {
@Override
public void execute() {
start(200, true);
getService().createNewModelPage(getEntryPoint(), title, description, copyId, isModelGroup, this);
}
@Override
protected void onResponse(final CmsModelPageEntry result) {
stop(false);
if (isModelGroup) {
CmsSitemapView.getInstance().displayNewModelPage(result, true);
} else {
loadNewElementInfo(new AsyncCallback() {
public void onFailure(Throwable caught) {
// nothing to do
}
public void onSuccess(Void v) {
CmsSitemapView.getInstance().displayNewModelPage(result, false);
}
});
}
}
};
action.execute();
}
/**
* Creates a sitemap folder.
*
* @param newEntry the new entry
* @param parentId the entry parent id
* @param sitemapType the resource type for the subsitemap folder
*/
public void createSitemapSubEntry(final CmsClientSitemapEntry newEntry, CmsUUID parentId, String sitemapType) {
CmsUUID structureId = m_data.getDefaultNewElementInfo().getCopyResourceId();
newEntry.setResourceTypeName(sitemapType);
create(newEntry, parentId, m_data.getDefaultNewElementInfo().getId(), structureId, null, true);
}
/**
* Creates a new sub-entry which is a subsitemap.
*
* @param parent the parent entry
* @param sitemapFolderType the sitemap folder type
*/
public void createSitemapSubEntry(final CmsClientSitemapEntry parent, final String sitemapFolderType) {
CmsSitemapTreeItem item = CmsSitemapTreeItem.getItemById(parent.getId());
AsyncCallback callback = new AsyncCallback() {
public void onFailure(Throwable caught) {
// do nothing
}
public void onSuccess(CmsClientSitemapEntry result) {
final CmsClientSitemapEntry newEntry = makeNewEntry(parent);
newEntry.setResourceTypeName(sitemapFolderType);
createSitemapSubEntry(newEntry, parent.getId(), sitemapFolderType);
}
};
if (item.getLoadState().equals(LoadState.UNLOADED)) {
getChildren(parent.getId(), true, callback);
} else {
callback.onSuccess(parent);
}
}
/**
* Creates a new sub-entry of an existing sitemap entry.
*
* @param parent the entry to which a new sub-entry should be added
*/
public void createSubEntry(final CmsClientSitemapEntry parent) {
createSubEntry(parent, null);
}
/**
* Creates a new sub-entry of an existing sitemap entry.
*
* @param parent the entry to which a new sub-entry should be added
* @param structureId the structure id of the model page (if null, uses default model page)
*/
public void createSubEntry(final CmsClientSitemapEntry parent, final CmsUUID structureId) {
CmsSitemapTreeItem item = CmsSitemapTreeItem.getItemById(parent.getId());
AsyncCallback callback = new AsyncCallback() {
public void onFailure(Throwable caught) {
// nothing to do
}
public void onSuccess(CmsClientSitemapEntry result) {
final CmsClientSitemapEntry newEntry = makeNewEntry(parent);
createSubEntry(newEntry, parent.getId(), structureId);
}
};
if (item.getLoadState().equals(LoadState.UNLOADED)) {
getChildren(parent.getId(), true, callback);
} else {
callback.onSuccess(parent);
}
}
/**
* Registers a new sitemap entry.
*
* @param newEntry the new entry
* @param parentId the parent entry id
* @param structureId the structure id of the model page (if null, uses default model page)
*/
public void createSubEntry(final CmsClientSitemapEntry newEntry, CmsUUID parentId, CmsUUID structureId) {
if (structureId == null) {
structureId = m_data.getDefaultNewElementInfo().getCopyResourceId();
}
create(newEntry, parentId, m_data.getDefaultNewElementInfo().getId(), structureId, null, false);
}
/**
* Creates a sub-sitemap from the subtree of the current sitemap starting at the given entry.
*
* @param entryId the id of the entry
*/
public void createSubSitemap(final CmsUUID entryId) {
CmsRpcAction subSitemapAction = new CmsRpcAction() {
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
*/
@Override
public void execute() {
start(0, true);
getService().createSubSitemap(entryId, this);
}
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
*/
@Override
protected void onResponse(CmsSitemapChange result) {
stop(false);
applyChange(result);
}
};
subSitemapAction.execute();
}
/**
* Deletes the given entry and all its descendants.
*
* @param sitePath the site path of the entry to delete
*/
public void delete(String sitePath) {
CmsClientSitemapEntry entry = getEntry(sitePath);
CmsClientSitemapEntry parent = getEntry(CmsResource.getParentFolder(entry.getSitePath()));
CmsSitemapChange change = new CmsSitemapChange(entry.getId(), entry.getSitePath(), ChangeType.delete);
change.setParentId(parent.getId());
change.setDefaultFileId(entry.getDefaultFileId());
CmsSitemapClipboardData data = CmsSitemapView.getInstance().getController().getData().getClipboardData().copy();
if (!entry.isNew()) {
data.addDeleted(entry);
removeDeletedFromModified(entry, data);
}
change.setClipBoardData(data);
CmsDetailPageTable detailPageTable = CmsSitemapView.getInstance().getController().getData().getDetailPageTable();
CmsUUID id = entry.getId();
if (detailPageTable.contains(id)) {
CmsDetailPageTable copyTable = detailPageTable.copy();
copyTable.remove(id);
change.setDetailPageInfos(copyTable.toList());
}
commitChange(change, null);
}
/**
* Deletes a category.
*
* @param id the id of the category
*/
public void deleteCategory(final CmsUUID id) {
CmsDeleteWarningDialog deleteWarningDialog = new CmsDeleteWarningDialog(id) {
@Override
protected void onAfterDeletion() {
CmsSitemapView.getInstance().getController().loadCategories(true);
}
};
deleteWarningDialog.loadAndShow(null);
}
/**
* Disables the given model page entry within the configuration.
*
* @param id the entry id
* @param disable true
to disable the entry
*/
public void disableModelPage(final CmsUUID id, final boolean disable) {
CmsRpcAction action = new CmsRpcAction() {
@Override
public void execute() {
start(200, true);
getService().disableModelPage(getEntryPoint(), id, disable, this);
}
@Override
protected void onResponse(Void result) {
stop(false);
CmsSitemapView.getInstance().updateModelPageDisabledState(id, disable);
}
};
action.execute();
}
/**
* Edits the given sitemap entry.
*
* @param entry the sitemap entry to update
* @param propertyChanges the property changes
* @param reloadStatus a value indicating which entries need to be reloaded after the change
*/
public void edit(
CmsClientSitemapEntry entry,
List propertyChanges,
final CmsReloadMode reloadStatus) {
CmsSitemapChange change = getChangeForEdit(entry, propertyChanges);
final String updateTarget = ((reloadStatus == CmsReloadMode.reloadParent))
? getParentEntry(entry).getSitePath()
: entry.getSitePath();
Command callback = new Command() {
public void execute() {
if ((reloadStatus == CmsReloadMode.reloadParent) || (reloadStatus == CmsReloadMode.reloadEntry)) {
updateEntry(updateTarget);
}
}
};
if (change != null) {
commitChange(change, callback);
}
}
/**
* Edits an entry and changes its URL name.
*
* @param entry the entry which is being edited
* @param newUrlName the new URL name of the entry
* @param propertyChanges the property changes
* @param keepNewStatus true
if the entry should keep it's new status
* @param reloadStatus a value indicating which entries need to be reloaded after the change
*/
public void editAndChangeName(
final CmsClientSitemapEntry entry,
String newUrlName,
List propertyChanges,
final boolean keepNewStatus,
final CmsReloadMode reloadStatus) {
CmsSitemapChange change = getChangeForEdit(entry, propertyChanges);
change.setName(newUrlName);
final CmsUUID entryId = entry.getId();
final boolean newStatus = keepNewStatus && entry.isNew();
final CmsUUID updateTarget = ((reloadStatus == CmsReloadMode.reloadParent))
? getParentEntry(entry).getId()
: entryId;
Command callback = new Command() {
public void execute() {
if ((reloadStatus == CmsReloadMode.reloadParent) || (reloadStatus == CmsReloadMode.reloadEntry)) {
updateEntry(updateTarget);
}
getEntryById(entryId).setNew(newStatus);
}
};
commitChange(change, callback);
}
/**
* Ensure the uniqueness of a given URL-name within the children of the given parent site-map entry.
*
* @param parent the parent entry
* @param newName the proposed name
*
* @return the unique name
*/
public String ensureUniqueName(CmsClientSitemapEntry parent, String newName) {
return ensureUniqueName(parent.getSitePath(), newName);
}
/**
* Ensure the uniqueness of a given URL-name within the children of the given parent folder.
*
* @param parentFolder the parent folder
* @param newName the proposed name
*
* @return the unique name
*/
public String ensureUniqueName(final String parentFolder, String newName) {
// using lower case folder names
final String lowerCaseName = newName.toLowerCase();
CmsRpcAction action = new CmsRpcAction() {
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
*/
@Override
public void execute() {
start(0, false);
CmsCoreProvider.getService().getUniqueFileName(parentFolder, lowerCaseName, this);
}
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
*/
@Override
protected void onResponse(String result) {
stop(false);
}
};
return action.executeSync();
}
/**
* Applies the given property modification.
*
* @param propMod the property modification to apply
*/
public void executePropertyModification(CmsPropertyModification propMod) {
CmsClientSitemapEntry entry = getEntryById(propMod.getId());
if (entry != null) {
Map props = getPropertiesForId(propMod.getId());
if (props != null) {
propMod.updatePropertyInMap(props);
entry.setOwnProperties(props);
}
}
}
/**
* Gets the category data.
*
* @return the category data
*/
public CmsSitemapCategoryData getCategoryData() {
return m_categoryData;
}
/**
* Retrieves the child entries of the given node from the server.
*
* @param entryId the entry id
* @param setOpen if the entry should be opened
*
* @param callback the callback to execute after the children have been loaded
*/
public void getChildren(
final CmsUUID entryId,
final boolean setOpen,
final AsyncCallback callback) {
getChildren(entryId, setOpen, false, callback);
}
/**
* Retrieves the child entries of the given node from the server.
*
* @param entryId the entry id
* @param setOpen if the entry should be opened
* @param continueIfParentNotLoaded if false, and the entry identified by the id has not been loaded, stop; else store the entry in memory
*
* @param callback the callback to execute after the children have been loaded
*/
public void getChildren(
final CmsUUID entryId,
final boolean setOpen,
final boolean continueIfParentNotLoaded,
final AsyncCallback callback) {
CmsRpcAction getChildrenAction = new CmsRpcAction() {
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
*/
@Override
public void execute() {
// Make the call to the sitemap service
start(500, false);
// loading grand children as well
getService().getChildren(getEntryPoint(), entryId, 2, this);
}
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
*/
@Override
public void onResponse(CmsClientSitemapEntry result) {
CmsClientSitemapEntry target = getEntryById(entryId);
if ((target == null) && !continueIfParentNotLoaded) {
// this might happen after an automated deletion
stop(false);
return;
}
CmsSitemapTreeItem item = null;
if (target != null) {
target.setSubEntries(result.getSubEntries(), CmsSitemapController.this);
item = CmsSitemapTreeItem.getItemById(target.getId());
target.update(result);
} else {
target = result;
}
target.initializeAll(CmsSitemapController.this);
if (item != null) {
item.updateEntry(target);
}
m_eventBus.fireEventFromSource(new CmsSitemapLoadEvent(target, setOpen), CmsSitemapController.this);
stop(false);
if (callback != null) {
callback.onSuccess(result);
}
}
};
getChildrenAction.execute();
}
/**
* Returns the sitemap data.
*
* @return the sitemap data
*/
public CmsSitemapData getData() {
return m_data;
}
/**
* Returns the detail page info for a given entry id.
*
* @param id a sitemap entry id
*
* @return the detail page info for that id
*/
public CmsDetailPageInfo getDetailPageInfo(CmsUUID id) {
return m_allDetailPageInfos.get(id);
}
/**
* Returns the detail page table.
*
* @return the detail page table
*/
public CmsDetailPageTable getDetailPageTable() {
return m_detailPageTable;
}
/**
* Gets the effective value of a property value for a sitemap entry.
*
* @param entry the sitemap entry
* @param name the name of the property
*
* @return the effective value
*/
public String getEffectiveProperty(CmsClientSitemapEntry entry, String name) {
CmsClientProperty prop = getEffectivePropertyObject(entry, name);
if (prop == null) {
return null;
}
return prop.getEffectiveValue();
}
/**
* Gets the value of a property which is effective at a given sitemap entry.
*
* @param entry the sitemap entry
* @param name the name of the property
* @return the effective property value
*/
public CmsClientProperty getEffectivePropertyObject(CmsClientSitemapEntry entry, String name) {
Map dfProps = entry.getDefaultFileProperties();
CmsClientProperty result = safeLookup(dfProps, name);
if (!CmsClientProperty.isPropertyEmpty(result)) {
return result.withOrigin(entry.getSitePath());
}
result = safeLookup(entry.getOwnProperties(), name);
if (!CmsClientProperty.isPropertyEmpty(result)) {
return result.withOrigin(entry.getSitePath());
}
return getInheritedPropertyObject(entry, name);
}
/**
* Returns all entries with an id from a given list.
*
* @param ids a list of sitemap entry ids
*
* @return all entries whose id is contained in the id list
*/
public Map getEntriesById(Collection ids) {
// TODO: use some map of id -> entry instead
List entriesToProcess = new ArrayList();
Map result = new HashMap();
entriesToProcess.add(m_data.getRoot());
while (!entriesToProcess.isEmpty()) {
CmsClientSitemapEntry entry = entriesToProcess.remove(entriesToProcess.size() - 1);
if (ids.contains(entry.getId())) {
result.put(entry.getId(), entry);
if (result.size() == ids.size()) {
return result;
}
}
entriesToProcess.addAll(entry.getSubEntries());
}
return result;
}
/**
* Returns the tree entry with the given path.
*
* @param entryPath the path to look for
*
* @return the tree entry with the given path, or null
if not found
*/
public CmsClientSitemapEntry getEntry(String entryPath) {
return m_entriesByPath.get(entryPath);
}
/**
* Finds an entry by id.
*
* @param id the id of the entry to find
*
* @return the found entry, or null if the entry wasn't found
*/
public CmsClientSitemapEntry getEntryById(CmsUUID id) {
return m_entriesById.get(id);
}
/**
* Returns the gallery type with the given id.
*
* @param typeId the type id
*
* @return the gallery type
*/
public CmsGalleryType getGalleryType(Integer typeId) {
return m_galleryTypes.get(typeId);
}
/**
* Gets the value for a property which a sitemap entry would inherit if it didn't have its own properties.
*
* @param entry the sitemap entry
* @param name the property name
* @return the inherited property value
*/
public String getInheritedProperty(CmsClientSitemapEntry entry, String name) {
CmsClientProperty prop = getInheritedPropertyObject(entry, name);
if (prop == null) {
return null;
}
return prop.getEffectiveValue();
}
/**
* Gets the property object which would be inherited by a sitemap entry.
*
* @param entry the sitemap entry
* @param name the name of the property
* @return the property object which would be inherited
*/
public CmsClientProperty getInheritedPropertyObject(CmsClientSitemapEntry entry, String name) {
CmsClientSitemapEntry currentEntry = entry;
while (currentEntry != null) {
currentEntry = getParentEntry(currentEntry);
if (currentEntry != null) {
CmsClientProperty folderProp = currentEntry.getOwnProperties().get(name);
if (!CmsClientProperty.isPropertyEmpty(folderProp)) {
return folderProp.withOrigin(currentEntry.getSitePath());
}
}
}
CmsClientProperty parentProp = getParentProperties().get(name);
if (!CmsClientProperty.isPropertyEmpty(parentProp)) {
String origin = parentProp.getOrigin();
String siteRoot = CmsCoreProvider.get().getSiteRoot();
if (origin.startsWith(siteRoot)) {
origin = origin.substring(siteRoot.length());
}
return parentProp.withOrigin(origin);
}
return null;
}
/**
* Returns a list of all descendant sitemap entries of a given path which have already been loaded on the client.
*
* @param path the path for which the descendants should be collected
*
* @return the list of descendant sitemap entries
*/
public List getLoadedDescendants(String path) {
LinkedList remainingEntries = new LinkedList();
List result = new ArrayList();
CmsClientSitemapEntry entry = getEntry(path);
remainingEntries.add(entry);
while (remainingEntries.size() > 0) {
CmsClientSitemapEntry currentEntry = remainingEntries.removeFirst();
result.add(currentEntry);
for (CmsClientSitemapEntry subEntry : currentEntry.getSubEntries()) {
remainingEntries.add(subEntry);
}
}
return result;
}
/**
* Returns the no edit reason or null
if editing is allowed.
*
* @param entry the entry to get the no edit reason for
*
* @return the no edit reason
*/
public String getNoEditReason(CmsClientSitemapEntry entry) {
String reason = entry.getNoEditReason();
if (CmsStringUtil.isEmptyOrWhitespaceOnly(reason)) {
reason = null;
if ((entry.getLock() != null)
&& (entry.getLock().getLockOwner() != null)
&& !entry.getLock().isOwnedByUser()) {
reason = Messages.get().key(Messages.GUI_DISABLED_LOCKED_BY_1, entry.getLock().getLockOwner());
}
if (entry.hasBlockingLockedChildren()) {
reason = Messages.get().key(Messages.GUI_DISABLED_BLOCKING_LOCKED_CHILDREN_0);
}
}
return reason;
}
/**
* Returns the parent entry of a sitemap entry, or null if it is the root entry.
*
* @param entry a sitemap entry
*
* @return the parent entry or null
*/
public CmsClientSitemapEntry getParentEntry(CmsClientSitemapEntry entry) {
String path = entry.getSitePath();
String parentPath = CmsResource.getParentFolder(path);
if (parentPath == null) {
return null;
}
return getEntry(parentPath);
}
/**
* Gets the properties for a given structure id.
*
* @param id the structure id of a sitemap entry
*
* @return the properties for that structure id
*/
public Map getPropertiesForId(CmsUUID id) {
return m_propertyMaps.get(id);
}
/**
* Returns the sitemap service instance.
*
* @return the sitemap service instance
*/
public I_CmsSitemapServiceAsync getService() {
if (m_service == null) {
m_service = GWT.create(I_CmsSitemapService.class);
String serviceUrl = CmsCoreProvider.get().link("org.opencms.ade.sitemap.CmsVfsSitemapService.gwt");
((ServiceDefTarget)m_service).setServiceEntryPoint(serviceUrl);
}
return m_service;
}
/**
* Leaves the current sitemap to open the parent sitemap.
*/
public void gotoParentSitemap() {
openSiteMap(getData().getParentSitemap());
}
/**
* Hides the entry within the site navigation.
*
* Hidden entries will still be visible in the navigation mode of the sitemap editor.
* They will also have a NavText and a NavPos. Only when using the NavBuilder get navigation for folder method,
* they will not be included.
*
* @param entryId the entry id
*/
public void hideInNavigation(CmsUUID entryId) {
CmsClientSitemapEntry entry = getEntryById(entryId);
CmsSitemapChange change = getChangeForEdit(
entry,
Collections.singletonList(
new CmsPropertyModification(
entryId.toString()
+ "/"
+ CmsClientProperty.PROPERTY_NAVINFO
+ "/"
+ CmsClientProperty.PATH_STRUCTURE_VALUE,
CmsClientSitemapEntry.HIDDEN_NAVIGATION_ENTRY)));
commitChange(change, null);
}
/**
* Checks whether this entry belongs to a detail page.
*
* @param entry the entry to check
*
* @return true if this entry belongs to a detail page
*/
public boolean isDetailPage(CmsClientSitemapEntry entry) {
return (entry.getDetailpageTypeName() != null) || isDetailPage(entry.getId());
}
/**
* Returns true if the id is the id of a detail page.
*
* @param id the sitemap entry id
* @return true if the id is the id of a detail page entry
*/
public boolean isDetailPage(CmsUUID id) {
return m_allDetailPageInfos.containsKey(id);
}
/**
* Checks if the current sitemap is editable.
*
* @return true
if the current sitemap is editable
*/
public boolean isEditable() {
return CmsStringUtil.isEmptyOrWhitespaceOnly(m_data.getNoEditReason());
}
/**
* Checks whether a string is the name of a hidden property.
*
* A hidden property is a property which should not appear in the property editor
* because it requires special treatment.
*
* @param propertyName the property name which should be checked
*
* @return true if the argument is the name of a hidden property
*/
public boolean isHiddenProperty(String propertyName) {
if (propertyName.equals("secure") && !m_data.isSecure()) {
// "secure" property should not be editable in a site for which no secure server is configured
return true;
}
return m_hiddenProperties.contains(propertyName);
}
/**
* Returns true if the locale comparison mode is enabled.
*
* @return true if the locale comparison mode is enabled
*/
public boolean isLocaleComparisonEnabled() {
return m_data.isLocaleComparisonEnabled();
}
/**
* Checks if the given site path is the sitemap root.
*
* @param sitePath the site path to check
*
* @return true
if the given site path is the sitemap root
*/
public boolean isRoot(String sitePath) {
return m_data.getRoot().getSitePath().equals(sitePath);
}
/**
* Ask to save the page before leaving, if necessary.
*
* @param target the leaving target
*/
public void leaveEditor(String target) {
Window.Location.assign(CmsCoreProvider.get().link(target));
}
/**
* Loads and displays the category data.
*
* @param openLocalCategories true if the local category tree should be opened
*/
public void loadCategories(final boolean openLocalCategories) {
CmsRpcAction action = new CmsRpcAction() {
@Override
public void execute() {
start(200, false);
getService().getCategoryData(getEntryPoint(), this);
}
@Override
protected void onResponse(CmsSitemapCategoryData result) {
stop(false);
m_categoryData = result;
CmsSitemapView.getInstance().displayCategoryData(result, openLocalCategories);
}
};
action.execute();
}
/**
* Loads all available galleries for the current sub site.
*/
public void loadGalleries() {
CmsRpcAction