/** * @see org.opencms.ui.contextmenu.I_CmsHasMenuItemVisibility#getVisibility(org.opencms.file.CmsObject, java.util.List) */ public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, List<CmsResource> resources) { boolean visible = ((resources == null) || resources.isEmpty()) && cms.existsResource(CmsWorkplace.JSP_WORKPLACE_URI); return visible ? CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE : CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE; } }
/** Removes the resources not accessible with the provided {@link CmsObject}. * * @param cms the {@link CmsObject} used to read the resources. * @param sitePaths site relative paths of the resources that should be checked for accessibility. * @return site paths of the accessible resources. */ private static List<String> removeNonAccessible(CmsObject cms, List<String> sitePaths) { List<String> result = new ArrayList<String>(sitePaths.size()); for (String sitePath : sitePaths) { if (cms.existsResource(sitePath, CmsResourceFilter.ALL)) { result.add(sitePath); } } return result; }
/** * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible() */ @Override public boolean isVisible() { String path = (String)getItem().get(LIST_COLUMN_NAME); if (path.contains("|")) { path = path.substring(path.indexOf("|") + 1); } return getCms().existsResource(path); }
/** * Loads a list of module configurations from the VFS.<p> * * @return the module configurations */ protected List<CmsADEConfigDataInternal> loadModuleConfiguration() { if (m_cms.existsResource("/")) { CmsConfigurationReader reader = new CmsConfigurationReader(m_cms); List<CmsADEConfigDataInternal> moduleConfigs = reader.readModuleConfigurations(); return moduleConfigs; } else { return Collections.emptyList(); } }
/** * Copies the explorer type icons.<p> * * @param iconPaths the path to the location where the icons are located * * @throws CmsException if something goes wrong */ private void cloneExplorerTypeIcons(Map<String, String> iconPaths) throws CmsException { for (Map.Entry<String, String> entry : iconPaths.entrySet()) { String source = ICON_PATH + entry.getKey(); String target = ICON_PATH + entry.getValue(); if (getCms().existsResource(source) && !getCms().existsResource(target)) { getCms().copyResource(source, target); } } }
/** * Sets the "start folder" setting.<p> * * @param value the start folder to show in the explorer view */ public void setParamTabWpFolder(String value) { // perform self - healing if (!getCms().existsResource(value, CmsResourceFilter.IGNORE_EXPIRATION)) { value = "/"; } m_userSettings.setStartFolder(value); }
/** * Returns true if the online help for the users current workplace language is installed.<p> * * @return true if the online help for the users current workplace language is installed */ public boolean isHelpEnabled() { return getCms().existsResource( resolveMacros(CmsHelpTemplateBean.PATH_HELP), CmsResourceFilter.IGNORE_EXPIRATION); }
/** * Sets the "start folder" setting.<p> * * @param value the start folder to show in the explorer view */ public void setParamTabWpFolder(String value) { // perform self - healing if (!getCms().existsResource(value, CmsResourceFilter.IGNORE_EXPIRATION)) { value = "/"; } m_userSettings.setStartFolder(value); }
/** * Checks if the published resource is inside the time window set with release and expiration date.<p> * * @param resource the published resource to check * @return true if the published resource is inside the time window, otherwise false */ protected boolean isResourceInTimeWindow(CmsPublishedResource resource) { return m_cms.existsResource( m_cms.getRequestContext().removeSiteRoot(resource.getRootPath()), CmsResourceFilter.DEFAULT); }
/** * Checks if the published resource is inside the time window set with release and expiration date.<p> * * @param resource the published resource to check * @return true if the published resource is inside the time window, otherwise false */ protected boolean isResourceInTimeWindow(CmsPublishedResource resource) { return m_cms.existsResource( m_cms.getRequestContext().removeSiteRoot(resource.getRootPath()), CmsResourceFilter.DEFAULT); }
/** * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible() */ @Override public boolean isVisible() { String path = (String)getItem().get(LIST_COLUMN_NAME); return getCms().existsResource(path); }
/** * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getVisibility(org.opencms.file.CmsObject) */ public CmsAppVisibilityStatus getVisibility(CmsObject cms) { boolean visible = cms.existsResource(m_toolHandler.getLink()) && m_toolHandler.isVisible(cms); return new CmsAppVisibilityStatus(visible, m_toolHandler.isEnabled(cms), ""); }
/** * Returns the most possible right resource name.<p> * * @return the most possible right resource name */ private String getResourceName() { String resource = getItem().get(m_resColumnPathId).toString(); if (!getWp().getCms().existsResource(resource, CmsResourceFilter.DEFAULT)) { String siteRoot = OpenCms.getSiteManager().getSiteRoot(resource); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(siteRoot)) { resource = resource.substring(siteRoot.length()); } if (!getWp().getCms().existsResource(resource, CmsResourceFilter.DEFAULT)) { resource = null; } } return resource; } }
/** * Creates a new folder in the given target folder.<p> * * @param targetFolder the target folder * @param folderName the new folder to create in the target folder * @return the created folder * @throws Exception if somthing goes wrong */ public CmsResource createFolder(String targetFolder, String folderName) throws Exception { if (m_cms.existsResource(targetFolder + folderName)) { m_shell.getOut().println( getMessages().key(Messages.GUI_SHELL_FOLDER_ALREADY_EXISTS_1, targetFolder + folderName)); return null; } return m_cms.createResource(targetFolder + folderName, CmsResourceTypeFolder.getStaticTypeId()); }
protected boolean hasReadPermission(CmsObject cms, String type, String path) { if (!isCheckingPermissions()) { return true; } if ((type == null) || (path == null)) { // permission check needs only to be performed for VFS documents that contain both fields return true; } if (!CmsSearchFieldConfiguration.VFS_DOCUMENT_KEY_PREFIX.equals(type) && !OpenCms.getResourceManager().hasResourceType(type)) { // this is not a known VFS resource type (also not the generic "VFS" type of OpenCms before 7.0) return true; } // check if the resource exits in the VFS, // this will implicitly check read permission and if the resource was deleted String contextPath = cms.getRequestContext().removeSiteRoot(path); return cms.existsResource(contextPath); }
/** * Adds the shared folder.<p> */ public void addSharedSite() { String shared = OpenCms.getSiteManager().getSharedFolder(); if (shared.endsWith("/")) { // IMPORTANT: remove last "/". // Otherwise the version without slash will be added as well when you are in the shared folder currently. shared = shared.substring(0, shared.length() - 1); } if ((shared != null) && m_cms.existsResource(shared, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) { addOption( Type.shared, shared, org.opencms.workplace.Messages.get().getBundle( OpenCms.getWorkplaceManager().getWorkplaceLocale(m_cms)).key( org.opencms.workplace.Messages.GUI_SHARED_TITLE_0)); } }
/** * Creates the content directory for this configuration node if possible.<p> * * @throws CmsException if something goes wrong */ protected void createContentDirectory() throws CmsException { if (!isModuleConfiguration()) { String contentFolder = getContentFolderPath(); if (!getCms().existsResource(contentFolder)) { getCms().createResource( contentFolder, OpenCms.getResourceManager().getResourceType(CmsResourceTypeFolder.getStaticTypeName())); } } }
/** * Sets the VFS folder under which XML contents will be processed recursively.<p> * * @param vfsFolder the VFS folder under which XML contents will be processed recursively * * @throws CmsIllegalArgumentException if the given VFS path is not valid */ public void setVfsFolder(String vfsFolder) throws CmsIllegalArgumentException { if (CmsStringUtil.isEmptyOrWhitespaceOnly(vfsFolder)) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_VALUE_EMPTY_0)); } // test if it is a valid path if (!m_cms.existsResource(vfsFolder, CmsResourceFilter.ALL.addRequireFolder())) { throw new CmsIllegalArgumentException( Messages.get().container(Messages.ERR_XMLCONTENT_VFSFOLDER_1, vfsFolder)); } m_vfsFolder = vfsFolder; }
/** The dialog mode. */ public static enum DialogMode { /** Allow copy only. */ copy, /** Allow copy and move. */ copy_and_move, /** Allow move only. */ move }
/** * @see org.opencms.gwt.shared.rpc.I_CmsCoreService#unlock(java.lang.String) */ public String unlock(String sitePath) throws CmsRpcException { try { CmsObject cms = OpenCms.initCmsObject(getCmsObject()); cms.getRequestContext().setSiteRoot(""); if (cms.existsResource(sitePath, CmsResourceFilter.IGNORE_EXPIRATION)) { CmsResource resource = cms.readResource(sitePath, CmsResourceFilter.IGNORE_EXPIRATION); tryUnlock(resource); } } catch (CmsException e) { return e.getLocalizedMessage(OpenCms.getWorkplaceManager().getWorkplaceLocale(getCmsObject())); } catch (Throwable e) { error(e); } return null; }