Creates the full path to the property file of the given resource.<p>

@param res the resource where to create the path for the property file for

@return the full path to the property file of the resource
976115
private String getPropertyFileName(CmsResource res) {

        StringBuffer ret = new StringBuffer();

        // path to the parent folder
        String parentFolder = CmsResource.getParentFolder(res.getRootPath());
        ret.append(parentFolder);

        // make sure ends with a slash
        if (!parentFolder.endsWith("/")) {
            ret.append("/");
        }

        // append name of the property folder
        ret.append(PROPERTY_DIR);
        ret.append("/");

        // if resource is a folder add the prefix "__"
        if (res.isFolder()) {
            ret.append(FOLDER_PREFIX);
        }

        // append the name of the resource
        ret.append(res.getName());

        return ret.toString();
    }
516604
protected String getUriTemplate(CmsObject cms, CmsResource res) {

        String result = "";
        try {
            result = cms.readPropertyObject(
                cms.getRequestContext().removeSiteRoot(res.getRootPath()),
                CmsPropertyDefinition.PROPERTY_TEMPLATE,
                true).getValue("");
        } catch (CmsException e) {
            // noop
        }
        return result;
    }
1233465
@Nullable
  public static Properties loadPropertiesFromResource(URL resource) {
    try (InputStream stream = resource.openStream()) {
      return loadProperties(stream);
    } catch (IOException e) {
      LOG.warn("Failed to read properties from {}: {}", resource, e.toString());
      return null;
    }
  }
1267865
public static File getResourceAsFile(String resource) {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        try {
            return new File(URLDecoder.decode(cl.getResource(resource)
                    .getFile(), "UTF-8"));
        } catch (UnsupportedEncodingException uee) {
            return null;
        }
    }
1246831
private String getRootPath(String path, int rootLevel, ResourceResolver resourceResolver) {
    String rootPath = Path.getAbsoluteParent(path, rootLevel, resourceResolver);

    // strip off everything after first "." - root path may be passed with selectors/extension which is not relevant
    if (StringUtils.contains(rootPath, ".")) {
      rootPath = StringUtils.substringBefore(rootPath, ".");
    }

    return rootPath;
  }
14062
public static String getResourcePath(String resource) {
		String path = null;
		ClassLoader[] loaders = getClassLoaders(null);
		for (int i = 0; i < loaders.length; i++) {
			if (loaders[i] != null) {
				try {
					path = loaders[i].getResource(resource).getPath();
					if (StringUtils.isNotBlank(path)) {
						return path;
					}
				} catch (NullPointerException e) {

				}
			}
		}
		return path;
	}
877654
public String getFullPath() {

        String path = m_resource.getRootPath();
        if ((m_siteMode != SITE_MODE_ROOT) && (m_cms != null)) {
            String site = getSite();
            if (path.startsWith(site)) {
                path = path.substring(site.length());
            }
        }
        return path;
    }
701225
protected String getResourceTypeFromProperties(Map<String, PropertyData<?>> properties, String defaultValue) {

        PropertyData<?> typeProp = properties.get(CmsCmisTypeManager.PROPERTY_RESOURCE_TYPE);
        String resTypeName = defaultValue;
        if (typeProp != null) {
            resTypeName = (String)typeProp.getFirstValue();
        }
        return resTypeName;
    }
751865
public URL getResource(String p) throws MalformedURLException
  {
    String rPath = null;

   /*
     * The spec states the resource must start with a / so if one isn't there we
     * prepend one.
     */
    // Begin 263020
    if (p.charAt(0) != '/' && p.charAt(0) != '\\')
    {
      if (prependSlashToResource)
      {
        logger.logp(Level.WARNING, CLASS_NAME, "getResource", "resource.path.has.to.start.with.slash");
        rPath = "/" + p;
      }
      else
      {
        throw new MalformedURLException(nls.getString("resource.path.has.to.start.with.slash"));
      }
    }
    else
    {
      rPath = p;
    }
    // End 263020
    
    if (container != null) {
        //Can not call getEntry with / on the root container
        if (p.equals("/")) {
            Collection<URL> urls = container.getURLs();
            Iterator<URL> it = urls.iterator();
            if (it.hasNext()) {
                URL url = it.next();  //get the first url
                
                if (url.getProtocol().equals("file")) { 
                    File file = new File(url.getFile());
                    if (file.exists() && !file.isDirectory()){  //might be a file:/xxx.war
                        return new URL("jar", "", -1, url + "!/");  //return jar:file:/xxx.war!/
                    }
                } 

                return url;
            }
        } else {
            Entry entry = container.getEntry(rPath);
            if (entry != null) {
                return entry.getResource();
            } else {
                return getDocumentRootUtils(rPath).getURL(rPath,metaInfCache);
            }
        }
    }

    String uri = getRealPath(rPath);
    if (uri == null)
    {
      return null;
    }

    java.io.File checkFile = new java.io.File(uri);
    if (!checkFile.exists())
    {
      if (!WCCustomProperties.SKIP_META_INF_RESOURCES_PROCESSING)
      {
        if (useMetaInfCache)
        {
          if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
          {
            logger.logp(Level.FINE, CLASS_NAME, "getResource", "trying META-INF/resources cache");
          }
          synchronized (metaInfCache)
          {
            if (metaInfCache.containsKey(rPath))
            {
              URL cachedURL = metaInfCache.get(rPath);
              if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
              {
                logger.logp(Level.FINE, CLASS_NAME, "getResource", "got cached META-INF name->[{0}], URL->[{1}]", new Object[] { rPath, cachedURL });
              }
              return cachedURL;
            }
          }
        }
        // URL otherURL = getWebInfLibClassloader().getResource(metaInfPath);
        MetaInfResourcesFileUtils metaInfFileUtil = new MetaInfResourcesFileUtils(this);
        metaInfFileUtil.findInMetaInfResource(rPath);
        URL metaInfURL = metaInfFileUtil.getURL();
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
        {
          logger.logp(Level.FINE, CLASS_NAME, "getResource", "file did not exist, trying META-INF/resources");
          logger.logp(Level.FINE, CLASS_NAME, "getResource", "metaInfPath->/META-INF/resources" + rPath);
        }
        if (useMetaInfCache)
        {
          if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
          {
            logger.logp(Level.FINE, CLASS_NAME, "getResource", "adding to META-INF cache name->[{0}], URL->[{1}]", new Object[] { rPath, metaInfURL });
          }
          synchronized (metaInfCache)
          {
            metaInfCache.put(rPath, metaInfURL);
          }
        }
        return metaInfURL;

      }
      else
      {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
        {
          logger.logp(Level.FINE, CLASS_NAME, "getResource", "skipping META-INF/resources processing");
        }
        return null;
      }
    }
    return checkFile.toURL();

  }
1182851
private File getFileFromProperty(final String name, final Properties props) {
        return getFileFromPath(props.getProperty(name));
    }
837462
private final Properties loadPropertiesFile(WsResource res) throws IOException {

        Properties props = new Properties();
        InputStream is = res.get();
        try {
            props.load(is);
        } catch (IOException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(this, tc, "Error loading properties; " + e);
            }
            throw e;
        } finally {
            if (is != null)
                try {
                    is.close();
                } catch (IOException e) {
                }
        }
        return props;
    }
1309628
public File getPropertiesFile() {
        final String path = line.getOptionValue(ARGUMENT.PROP);
        if (path != null) {
            return new File(path);
        }
        return null;
    }
502362
static ResourcePath create(String resourceName) {
    String[] parts = resourceName.split("/");

    if (parts.length >= 6 && parts[0].equals("projects") && parts[2].equals("databases")) {
      String[] path = Arrays.copyOfRange(parts, 5, parts.length);
      return create(
          DatabaseRootName.of(parts[1], parts[3]),
          ImmutableList.<String>builder().add(path).build());
    }

    return create(DatabaseRootName.parse(resourceName));
  }
1261535
private String getLoginFormURL(HttpServletRequest req, HttpServletResponse res) throws IOException {

        CmsHttpAuthenticationSettings httpAuthenticationSettings = OpenCms.getSystemInfo().getHttpAuthenticationSettings();
        String loginFormURL = null;

        // this will create an admin user with the "right" site root already set
        CmsObject adminCms;
        try {
            adminCms = initCmsObject(req, res, OpenCms.getDefaultUsers().getUserAdmin(), null, null);
        } catch (CmsException e) {
            // this should never happen, if it does we can't continue
            throw new IOException(
                Messages.get().getBundle().key(
                    Messages.ERR_INVALID_INIT_USER_2,
                    OpenCms.getDefaultUsers().getUserAdmin(),

                    null),
                e);
        }
        // get the requested resource
        String path = adminCms.getRequestContext().getUri();
        CmsProperty propertyLoginForm = null;
        try {
            propertyLoginForm = adminCms.readPropertyObject(path, CmsPropertyDefinition.PROPERTY_LOGIN_FORM, true);
        } catch (Throwable t) {
            if (t instanceof CmsVfsResourceNotFoundException) {
                // if we can't read the property from the path, try to use the resource init handlers to find the
                // resource to read it from
                CmsResource alternativeResource = null;
                try {
                    // use null as the response to avoid side effects like redirects, etc.
                    alternativeResource = initResource(adminCms, path, req, null);
                    if (alternativeResource != null) {
                        propertyLoginForm = adminCms.readPropertyObject(
                            adminCms.getSitePath(alternativeResource),
                            CmsPropertyDefinition.PROPERTY_LOGIN_FORM,
                            true);
                    }
                } catch (Exception e) {
                    LOG.error(e.getLocalizedMessage(), e);
                }
            }

            if (propertyLoginForm == null) {
                if (LOG.isWarnEnabled()) {
                    LOG.warn(
                        Messages.get().getBundle().key(
                            Messages.LOG_ERROR_READING_AUTH_PROP_2,
                            CmsPropertyDefinition.PROPERTY_LOGIN_FORM,
                            path),
                        t);
                }

            }
        }

        String params = null;
        if ((propertyLoginForm != null)
            && (propertyLoginForm != CmsProperty.getNullProperty())
            && CmsStringUtil.isNotEmpty(propertyLoginForm.getValue())) {
            // login form property value was found
            // build a redirect URL using the value of the property
            // "__loginform" is a dummy request parameter that could be used in a JSP template to trigger
            // if the template should display a login formular or not
            loginFormURL = propertyLoginForm.getValue();
            params = "__loginform=true";
        } else if (!httpAuthenticationSettings.useBrowserBasedHttpAuthentication()
            && CmsStringUtil.isNotEmpty(httpAuthenticationSettings.getFormBasedHttpAuthenticationUri())) {
            // login form property value not set, but form login set in configuration
            // build a redirect URL to the default login form URI configured in opencms.properties
            loginFormURL = httpAuthenticationSettings.getFormBasedHttpAuthenticationUri();
        }

        String callbackURL = CmsRequestUtil.encodeParamsWithUri(path, req);
        if (loginFormURL != null) {
            if (!loginFormURL.startsWith("http")) {
                loginFormURL = m_linkManager.substituteLink(adminCms, loginFormURL, null, true);
            } else {
                callbackURL = m_linkManager.getServerLink(adminCms, path);
                callbackURL = CmsRequestUtil.encodeParamsWithUri(callbackURL, req);
            }
        }

        return m_authorizationHandler.getLoginFormURL(loginFormURL, params, callbackURL);
    }
1154878
private Path createPath(PathUri uri) {

    PathProvider provider = getProvider(uri);
    if (provider == null) {
      if (uri.getSchemePrefix() == null) {
        return Paths.get(uri.getPath());
      } else {
        try {
          return Paths.get(new URI(uri.getUri()));
        } catch (URISyntaxException e) {
          throw new ResourceUriUndefinedException(e, uri.getUri());
        }
      }
    }
    return provider.createResource(uri);
  }
143293
public static File getFileForResource(final String resourcePath) {
        URL path = ResourceUtil.class.getResource(resourcePath);
        if (path == null) {
            path = ResourceUtil.class.getResource("/");
            return new File(new File(path.getPath()), resourcePath);
        }

        return new File(path.getPath());
    }
808415
private String getCommonAncestorPath(Collection<CmsResource> resources) {

        if (resources.isEmpty()) {
            return "/";
        }
        String commonPath = null;
        for (CmsResource resource : resources) {
            commonPath = getCommonAncestorPath(commonPath, resource.getRootPath());
        }
        return commonPath;
    }