/*
(non-Javadoc)

@see com.sixdimensions.wcm.cq.component.bindings.jmx.
ComponentBindingsProviderFactoryMBean#getLoadedResourceTypes()
504958
@Override
	@Description("Gets all of th resource types which have bound Component Bindings Providers")
	public String[] getLoadedResourceTypes() {
		Set<String> types = ((ComponentBindingsProviderFactoryImpl) componentBindingsProviderFactory)
				.getLoadedResourceTypes();
		return types.toArray(new String[types.size()]);
	}
419808
public java.util.List<? extends com.google.iam.v1.BindingDeltaOrBuilder> 
      getBindingDeltasOrBuilderList() {
    return bindingDeltas_;
  }
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));
        }
    }
1319118
public String getIconPathResourceType() {

        if (!isEditable()) {
            return CmsWorkplace.RES_PATH_FILETYPES
                + OpenCms.getWorkplaceManager().getExplorerTypeSetting(
                    CmsResourceTypePlain.getStaticTypeName()).getIcon();
        }
        return CmsWorkplace.RES_PATH_FILETYPES
            + OpenCms.getWorkplaceManager().getExplorerTypeSetting(getResourceTypeName()).getIcon();
    }
1224089
@Override
	@Description("Gets all of the service references for the specified resource type")
	public TabularData getReferences(@Name("ResourceType") String resourceType)
			throws OpenDataException {
		List<ServiceReference> references = ((ComponentBindingsProviderFactoryImpl) componentBindingsProviderFactory)
				.getReferences(resourceType);

		String[] itemNames = { Constants.SERVICE_PID,
				ComponentBindingsProvider.PRIORITY,
				ComponentBindingsProvider.RESOURCE_TYPE_PROP };
		String[] itemDescriptions = { "The Service ID",
				"The Priority on which the binding service will be called",
				"The resource types this service will bind to" };
		OpenType<?>[] itemTypes = { SimpleType.STRING, SimpleType.STRING,
				SimpleType.STRING };
		CompositeType snapshotType = new CompositeType("references",
				"References", itemNames, itemDescriptions, itemTypes);
		TabularType quoteTableType = new TabularType("references",
				"References", snapshotType,
				new String[] { Constants.SERVICE_PID });
		TabularData td = new TabularDataSupport(quoteTableType);
		for (ServiceReference reference : references) {
			Map<String, Object> data = new HashMap<String, Object>();
			for (String itemName : itemNames) {
				if (reference.getProperty(itemName) instanceof String[]) {
					data.put(itemName, Arrays.toString((String[]) reference
							.getProperty(itemName)));
				} else {
					data.put(itemName, reference.getProperty(itemName));
				}
			}
			td.put(new CompositeDataSupport(snapshotType, data));
		}
		return td;
	}
1188364
@SuppressWarnings("deprecation")
    private List<CmsGalleryType> collectGalleryTypes() {

        Locale wpLocale = OpenCms.getWorkplaceManager().getWorkplaceLocale(getCmsObject());
        Map<String, List<String>> galleryContentTypes = new HashMap<String, List<String>>();
        List<CmsGalleryType> result = new ArrayList<CmsGalleryType>();
        for (I_CmsResourceType resourceType : OpenCms.getResourceManager().getResourceTypes()) {
            if (resourceType instanceof CmsResourceTypeFolderExtended) {
                // found a configured extended folder resource type
                CmsResourceTypeFolderExtended galleryType = (CmsResourceTypeFolderExtended)resourceType;
                String folderClassName = galleryType.getFolderClassName();
                if (CmsStringUtil.isNotEmpty(folderClassName)) {
                    // only process this as a gallery if the folder name is not empty
                    try {
                        // check, if the folder class is a subclass of A_CmsGallery
                        if (A_CmsAjaxGallery.class.isAssignableFrom(Class.forName(folderClassName))) {
                            CmsGalleryType gallery = new CmsGalleryType();
                            gallery.setTypeId(resourceType.getTypeId());
                            gallery.setResourceType(resourceType.getTypeName());
                            gallery.setTitle(
                                CmsWorkplaceMessages.getResourceTypeName(wpLocale, resourceType.getTypeName()));
                            gallery.setSubTitle(
                                CmsWorkplaceMessages.getResourceTypeDescription(wpLocale, resourceType.getTypeName()));
                            gallery.setBigIconClasses(
                                CmsIconUtil.getIconClasses(resourceType.getTypeName(), null, false));
                            result.add(gallery);
                        }
                    } catch (Exception e) {
                        this.log(e.getLocalizedMessage(), e);
                    }
                }
            } else {
                List<I_CmsResourceType> galleryTypes = resourceType.getGalleryTypes();
                if ((galleryTypes != null) && !galleryTypes.isEmpty()) {
                    for (I_CmsResourceType galleryType : galleryTypes) {
                        List<String> typeList = galleryContentTypes.get(galleryType.getTypeName());
                        if (typeList == null) {
                            typeList = new ArrayList<String>();
                            galleryContentTypes.put(galleryType.getTypeName(), typeList);
                        }
                        typeList.add(resourceType.getTypeName());
                    }
                }
            }
        }
        for (CmsGalleryType galleryType : result) {
            galleryType.setContentTypeNames(galleryContentTypes.get(galleryType.getResourceType()));
        }
        return result;
    }
1106603
@Override
	public List<ComponentBindingsProvider> getComponentBindingsProviders(
			String resourceType) {
		List<ComponentBindingsProvider> cis = new ArrayList<ComponentBindingsProvider>();
		for (ServiceReference reference : getReferences(resourceType)) {
			ComponentBindingsProvider ci = ComponentBindingsProvider.class
					.cast(bundleContext.getService(reference));
			cis.add(ci);
		}

		if (cis.size() != 0 && log.isDebugEnabled()) {
			log.debug(
					"Found {} Component Bindings Providers Services for resource type {}",
					cis.size(), resourceType);
		}

		return cis;
	}
228394
public static Stream<String> getResourceTypes(final Event event) {
        if (event instanceof org.modeshape.jcr.api.observation.Event) {
            try {
                final org.modeshape.jcr.api.observation.Event modeEvent =
                        (org.modeshape.jcr.api.observation.Event) event;
                final Stream.Builder<NodeType> types = Stream.builder();
                for (final NodeType type : modeEvent.getMixinNodeTypes()) {
                    types.add(type);
                }
                types.add(modeEvent.getPrimaryNodeType());
                return types.build().map(NodeType::getName);
            } catch (final RepositoryException e) {
                throw new RepositoryRuntimeException(e);
            }
        }
        return empty(); // wasn't a ModeShape event, so we have no access to resource types
    }
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;
  }
988008
public List<CmsResourceTypeBean> getPrecomputedTypes(CmsElementView view) {

        return Lists.newArrayList(m_cachedTypes.get(view.getId()));
    }
336793
private Collection<MethodMetadata<?, ?>> getMethodMetadataOfType(AnnotatedType annotatedType, Collection<AnnotatedMethod> annotatedMethods) {
        Collection<MethodMetadata<?, ?>> methodMetadataOfType = new ArrayList<>();
        // Collect the getter methods as they provide annotations holding meta
        // information also to be applied to setters
        for (AnnotatedMethod annotatedMethod : annotatedMethods) {
            MethodMetadata<?, ?> methodMetadata;
            ImplementedBy implementedBy = annotatedMethod.getAnnotation(ImplementedBy.class);
            ResultOf resultOf = annotatedMethod.getAnnotation(ResultOf.class);
            if (implementedBy != null) {
                methodMetadata = new ImplementedByMethodMetadata<>(annotatedMethod, implementedBy.value(),
                        metadataFactory.createImplementedByMetadata(annotatedMethod));
            } else if (resultOf != null) {
                methodMetadata = createResultOfMetadata(annotatedMethod, resultOf);
            } else if (annotatedMethod instanceof PropertyMethod) {
                PropertyMethod propertyMethod = (PropertyMethod) annotatedMethod;
                Transient transientAnnotation = propertyMethod.getAnnotationOfProperty(Transient.class);
                if (transientAnnotation != null) {
                    methodMetadata = new TransientPropertyMethodMetadata(propertyMethod);
                } else {
                    methodMetadata = createPropertyMethodMetadata(annotatedType, propertyMethod);
                }
            } else {
                methodMetadata = new UnsupportedOperationMethodMetadata((UserMethod) annotatedMethod);
            }
            methodMetadataOfType.add(methodMetadata);
        }
        return methodMetadataOfType;
    }
1262760
private synchronized void initResourceType(
        I_CmsResourceType resourceType,
        CmsResourceManagerConfiguration configuration) {

        // add the loader to the internal list of loaders
        configuration.addResourceType(resourceType);
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(
                Messages.get().getBundle().key(
                    Messages.INIT_ADD_RESTYPE_3,
                    resourceType.getTypeName(),
                    new Integer(resourceType.getTypeId()),
                    resourceType.getClass().getName()));
        }

        // add the mappings
        List<String> mappings = resourceType.getConfiguredMappings();
        Iterator<String> i = mappings.iterator();
        while (i.hasNext()) {
            String mapping = i.next();
            // only add this mapping if a mapping with this file extension does not
            // exist already
            if (!configuration.m_extensionMappings.containsKey(mapping)) {
                configuration.m_extensionMappings.put(mapping, resourceType.getTypeName());
                if (CmsLog.INIT.isInfoEnabled()) {
                    CmsLog.INIT.info(
                        Messages.get().getBundle().key(
                            Messages.INIT_MAP_RESTYPE_2,
                            mapping,
                            resourceType.getTypeName()));
                }
            }
        }
    }
742731
public String getResourceType() {
        if (!tokens.isEmpty() && tokens.getLast().hasKey()) {
            return tokens.getLast().getKey();
        }
        return null;
    }
674427
private String getResourceType(Resource resource)
   {
      String result;
      net.sf.mpxj.ResourceType type = resource.getType();
      if (type == null)
      {
         type = net.sf.mpxj.ResourceType.WORK;
      }

      switch (type)
      {
         case MATERIAL:
         {
            result = "Material";
            break;
         }

         case COST:
         {
            result = "Nonlabor";
            break;
         }

         default:
         {
            result = "Labor";
            break;
         }
      }

      return result;
   }
1041598
private static <L> void populateMetricTypesForResourceType(
            ResourceType.Builder<?, L> resourceTypeBuilder,
            TypeSets.Builder<L> typeSetsBuilder) {

        Map<Name, TypeSet<MetricType<L>>> metricTypeSets = typeSetsBuilder.getMetricTypeSets();
        List<Name> metricSetNames = resourceTypeBuilder.getMetricSetNames();
        for (Name metricSetName : metricSetNames) {
            TypeSet<MetricType<L>> metricSet = metricTypeSets.get(metricSetName);
            if (metricSet != null && metricSet.isEnabled()) {
                resourceTypeBuilder.metricTypes(metricSet.getTypeMap().values());
            }
        }

    }
1271092
private ResourceType getResourceType(String resourceTag) {
        if (resourceTag == null || !resourceTag.endsWith("-resource")) {
            return ResourceType.unknown;
        }

        try {
            return ResourceType.valueOf(resourceTag.substring(0, resourceTag.length() - 9));
        } catch (Exception e) {
            return ResourceType.unknown;
        }
    }
91838
public static List<I_CmsResourceType> getResourceTypes() {

        List<I_CmsResourceType> res = new ArrayList<I_CmsResourceType>();
        for (I_CmsResourceType type : OpenCms.getResourceManager().getResourceTypes()) {
            CmsExplorerTypeSettings typeSetting = OpenCms.getWorkplaceManager().getExplorerTypeSetting(
                type.getTypeName());
            if (typeSetting != null) {
                res.add(type);
            }
        }
        return res;
    }