Search in sources :

Example 1 with CommandResourceMetaData

use of org.glassfish.admin.rest.generator.CommandResourceMetaData in project Payara by payara.

the class ResourceUtil method getResourceLinks.

public static Map<String, String> getResourceLinks(Dom dom, UriInfo uriInfo, boolean canShowDeprecated) {
    Map<String, String> links = new TreeMap<String, String>();
    for (String elementName : dom.model.getElementNames()) {
        // for each element
        if (elementName.equals("*")) {
            ConfigModel.Node node = (ConfigModel.Node) dom.model.getElement(elementName);
            ConfigModel childModel = node.getModel();
            List<ConfigModel> lcm = getRealChildConfigModels(childModel, dom.document);
            Collections.sort(lcm, new ConfigModelComparator());
            if (lcm != null) {
                for (ConfigModel cmodel : lcm) {
                    if ((!isDeprecated(cmodel) || canShowDeprecated)) {
                        links.put(cmodel.getTagName(), ProviderUtil.getElementLink(uriInfo, cmodel.getTagName()));
                    }
                }
            }
        } else {
            ConfigModel.Property childElement = dom.model.getElement(elementName);
            boolean deprec = false;
            if (childElement instanceof ConfigModel.Node) {
                ConfigModel.Node node = (ConfigModel.Node) childElement;
                deprec = isDeprecated(node.getModel());
            }
            for (String annotation : childElement.getAnnotations()) {
                if (annotation.equals(Deprecated.class.getName())) {
                    deprec = true;
                }
            }
            if ((!deprec || canShowDeprecated)) {
                links.put(elementName, ProviderUtil.getElementLink(uriInfo, elementName));
            }
        }
    }
    String beanName = getUnqualifiedTypeName(dom.model.targetTypeName);
    for (CommandResourceMetaData cmd : CommandResourceMetaData.getCustomResourceMapping(beanName)) {
        links.put(cmd.resourcePath, ProviderUtil.getElementLink(uriInfo, cmd.resourcePath));
    }
    return links;
}
Also used : ConfigModel(org.jvnet.hk2.config.ConfigModel) CommandResourceMetaData(org.glassfish.admin.rest.generator.CommandResourceMetaData) TreeMap(java.util.TreeMap)

Aggregations

TreeMap (java.util.TreeMap)1 CommandResourceMetaData (org.glassfish.admin.rest.generator.CommandResourceMetaData)1 ConfigModel (org.jvnet.hk2.config.ConfigModel)1