Returns the resource type to create, or <code>null</code> if not available.<p>

@param resource the edit resource
@param createType the create type parameter

@return the resource type
351472
private static I_CmsResourceType getResourceType(CmsResource resource, String createType) {

        I_CmsResourceType resType = null;
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(createType)) {
            try {
                resType = OpenCms.getResourceManager().getResourceType(createType);
            } catch (CmsLoaderException e) {
                LOG.error("Could not read resource type '" + createType + "' for resource creation.", e);
            }
        } else if (resource != null) {
            resType = OpenCms.getResourceManager().getResourceType(resource);
        }
        return resType;
    }
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;
        }
    }
635366
public static boolean isXmlContent(CmsResource resource) {

        boolean result = false;
        if (resource != null) {
            // avoid array index out of bound exception:
            if (!resource.isFolder()) {
                result = OpenCms.getResourceManager().getResourceType(resource) instanceof CmsResourceTypeXmlContent;
            }
        }
        return result;
    }
384709
protected List<I_CmsResourceType> getDetailTypesForPage(CmsResource resource) {

        Collection<String> typesForPage = m_detailTypesByPage.get(resource.getRootPath());
        String parentPath = CmsFileUtil.removeTrailingSeparator(CmsResource.getParentFolder(resource.getRootPath()));
        Collection<String> typesForFolder = m_detailTypesByPage.get(parentPath);
        Set<String> allTypes = new HashSet<String>();
        allTypes.addAll(typesForPage);
        allTypes.addAll(typesForFolder);
        List<I_CmsResourceType> resTypes = new ArrayList<I_CmsResourceType>();
        CmsResourceManager resMan = OpenCms.getResourceManager();
        for (String typeName : allTypes) {
            if (typeName.startsWith(CmsDetailPageInfo.FUNCTION_PREFIX)) {
                continue;
            }
            try {
                I_CmsResourceType resType = resMan.getResourceType(typeName);
                resTypes.add(resType);
            } catch (CmsLoaderException e) {
                LOG.warn("Invalid resource type name" + typeName + "! " + e.getLocalizedMessage(), e);
            }
        }
        return resTypes;
    }
966795
public static Integer lookup(String type) throws IllegalArgumentException {
    checkNotNull(type, "resource type was null");
    checkArgument(lookup.containsKey(type), "%s do not include %s; types: %s",
                  ResourceTypes.class.getSimpleName(),
                  type, EnumSet.allOf(ResourceTypes.class));
    return lookup.get(type);
  }
895750
@Override
   @SuppressWarnings("unchecked")
   public <E, T extends Resource<E>> T getChildOfType(final Class<T> type, final String name) throws ResourceException
   {
      T result;
      Resource<?> child = getChild(name);
      if (type.isAssignableFrom(child.getClass()))
      {
         result = (T) child;
      }
      else if (child.exists())
      {
         throw new ResourceException("Requested resource [" + name + "] was not of type [" + type.getName()
                  + "], but was instead [" + child.getClass().getName() + "]");
      }
      else
      {
         E underlyingResource = (E) child.getUnderlyingResourceObject();
         result = getResourceFactory().create(type, underlyingResource);
      }
      return result;
   }
329876
public Integer getCount(ResourceType resourceType) {
    Integer count = typeToCountMap.get(resourceType);
    if (count == null) {
      return 0;
    } else {
      return count;
    }
  }
1057445
public static String getResourceName(Resource resource) {
        String result = null;
        if (resource != null) {
            String name = resource.getName();
            if (ResourceUtil.CONTENT_NODE.equals(name)) {
                result = getResourceName(resource.getParent());
            } else {
                result = name;
            }
        }
        return result;
    }
1226482
private <S> ConvertManagerTypeImpl<S> getOrCreate(Class<S> sourceType)
  {
    ConvertManagerTypeImpl<S> convertType
    = (ConvertManagerTypeImpl<S>) _convertMap.get(sourceType);
  
    if (convertType != null) {
      return convertType;
    }
    
    convertType = new ConvertManagerTypeImpl<>(sourceType);
    
    _convertMap.putIfAbsent(sourceType, convertType);

    return (ConvertManagerTypeImpl<S>) _convertMap.get(sourceType);
  }
825478
public static @Nullable String getExistingResourceType(@NotNull ResourceResolver resourceResolver, @NotNull String @NotNull... resourceTypes) {
    for (String path : resourceTypes) {
      if (resourceResolver.getResource(path) != null) {
        return path;
      }
    }
    return null;
  }
1114037
public static MimeType getMimeType(Resource resource) {
        MimeType result = null;
        if (resource != null) {
            ResourceHandle handle = ResourceHandle.use(resource);
            result = getMimeType(handle.getProperty(ResourceUtil.PROP_MIME_TYPE, ""));
            if (result == null) {
                String name = resource.getName();
                if (ResourceUtil.CONTENT_NODE.equals(name)) {
                    result = getParentMimeType(resource);
                } else {
                    result = getContentMimeType(resource);
                    if (result == null) {
                        String filename = getResourceName(resource);
                        result = getMimeType(filename);
                    }
                }
            }
        }
        return result;
    }
581697
public CmsSitemapTreeNodeData getData(CmsResource resource) {

        try {
            CmsVfsSitemapService svc = new CmsVfsSitemapService();
            CmsObject cms = OpenCms.initCmsObject(A_CmsUI.getCmsObject());
            cms.getRequestContext().setSiteRoot("");
            svc.setCms(cms);

            CmsClientSitemapEntry ent = svc.getChildren(resource.getRootPath(), resource.getStructureId(), 0);
            CmsSitemapTreeNodeData data = new CmsSitemapTreeNodeData(
                m_localeContext.getRootLocale(),
                m_localeContext.getComparisonLocale());
            data.setClientEntry(ent);
            data.initialize(cms);
            return data;
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
            return null;
        }

    }
87661
private synchronized void initResourceTypes() throws CmsConfigurationException {

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_STARTING_LOADER_CONFIG_0));
        }

        CmsResourceManagerConfiguration newConfiguration = new CmsResourceManagerConfiguration();

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(
                Messages.get().getBundle().key(
                    Messages.INIT_ADD_RESTYPE_FROM_FILE_2,
                    new Integer(m_resourceTypesFromXml.size()),
                    CmsVfsConfiguration.DEFAULT_XML_FILE_NAME));
        }

        // build a new resource type list from the resource types of the XML configuration
        Iterator<I_CmsResourceType> i;
        i = m_resourceTypesFromXml.iterator();
        while (i.hasNext()) {
            I_CmsResourceType resourceType = i.next();
            initResourceType(resourceType, newConfiguration);
        }

        // add all resource types declared in the modules
        CmsModuleManager moduleManager = OpenCms.getModuleManager();
        if (moduleManager != null) {
            Iterator<String> modules = moduleManager.getModuleNames().iterator();
            while (modules.hasNext()) {
                CmsModule module = moduleManager.getModule(modules.next());
                if ((module != null) && (module.getResourceTypes().size() > 0)) {
                    // module contains resource types
                    if (CmsLog.INIT.isInfoEnabled()) {
                        CmsLog.INIT.info(
                            Messages.get().getBundle().key(
                                Messages.INIT_ADD_NUM_RESTYPES_FROM_MOD_2,
                                new Integer(module.getResourceTypes().size()),
                                module.getName()));
                    }

                    Iterator<I_CmsResourceType> j = module.getResourceTypes().iterator();
                    while (j.hasNext()) {
                        I_CmsResourceType resourceType = j.next();
                        I_CmsResourceType conflictingType = null;
                        if (resourceType.getTypeId() == CmsResourceTypeUnknownFile.RESOURCE_TYPE_ID) {
                            // default unknown file resource type
                            if (m_restypeUnknownFile != null) {
                                // error: already set
                                conflictingType = m_restypeUnknownFile;
                            } else {
                                m_restypeUnknownFile = resourceType;
                                continue;
                            }
                        } else if (resourceType.getTypeId() == CmsResourceTypeUnknownFolder.RESOURCE_TYPE_ID) {
                            // default unknown folder resource type
                            if (m_restypeUnknownFolder != null) {
                                // error: already set
                                conflictingType = m_restypeUnknownFolder;
                            } else {
                                m_restypeUnknownFile = resourceType;
                                continue;
                            }
                        } else {
                            // normal resource types
                            conflictingType = newConfiguration.getResourceTypeById(resourceType.getTypeId());
                        }
                        if (conflictingType != null) {
                            throw new CmsConfigurationException(
                                Messages.get().container(
                                    Messages.ERR_CONFLICTING_MODULE_RESOURCE_TYPES_5,
                                    new Object[] {
                                        resourceType.getTypeName(),
                                        new Integer(resourceType.getTypeId()),
                                        module.getName(),
                                        conflictingType.getTypeName(),
                                        new Integer(conflictingType.getTypeId())}));
                        }
                        initResourceType(resourceType, newConfiguration);
                    }
                }
            }
        }

        // freeze the current configuration
        newConfiguration.freeze(m_restypeUnknownFile, m_restypeUnknownFile);
        m_configuration = newConfiguration;
        m_frozen = true;

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_RESOURCE_TYPE_INITIALIZED_0));
        }
    }
136109
@SuppressWarnings("deprecation")
    private CmsResourceTypeBean createTypeBean(
        I_CmsResourceType type,
        I_CmsPreviewProvider preview,
        boolean creatable) {

        CmsResourceTypeBean result = new CmsResourceTypeBean();

        result.setResourceType(type.getTypeName());
        result.setTypeId(type.getTypeId());
        Locale wpLocale = getWorkplaceLocale();
        // type title and subtitle
        result.setTitle(CmsWorkplaceMessages.getResourceTypeName(wpLocale, type.getTypeName()));
        result.setSubTitle(CmsWorkplaceMessages.getResourceTypeDescription(wpLocale, type.getTypeName()));
        result.setBigIconClasses(CmsIconUtil.getIconClasses(type.getTypeName(), null, false));
        // gallery id of corresponding galleries
        ArrayList<String> galleryNames = new ArrayList<String>();
        Iterator<I_CmsResourceType> galleryTypes = type.getGalleryTypes().iterator();
        while (galleryTypes.hasNext()) {
            I_CmsResourceType galleryType = galleryTypes.next();
            galleryNames.add(galleryType.getTypeName());
        }
        result.setGalleryTypeNames(galleryNames);
        if (preview != null) {
            result.setPreviewProviderName(preview.getPreviewName());
        }
        if (type.isFolder()) {
            result.setVisibility(TypeVisibility.hidden);
        }
        result.setCreatableType(creatable);
        return result;
    }
401336
private String getProviderName(String resourceType) {

        CmsDebugLog.consoleLog("getProviderName for " + resourceType);
        for (CmsResourceTypeBean typeBean : m_dialogBean.getTypes()) {
            if (typeBean.getType().equals(resourceType)) {
                return typeBean.getPreviewProviderName();
            }
        }
        return null;
    }
742731
public String getResourceType() {
        if (!tokens.isEmpty() && tokens.getLast().hasKey()) {
            return tokens.getLast().getKey();
        }
        return null;
    }
510691
public static <T, R extends Resource<T>> T getEntity(R resource) {
        return resource.getEntity();
    }