Search in sources :

Example 1 with ElementInfo

use of org.platformlayer.xml.XmlHelper.ElementInfo in project platformlayer by platformlayer.

the class SshAddressFinder method visit.

public void visit(UntypedItem item) throws PlatformLayerClientException {
    UntypedItemXml untypedItem = (UntypedItemXml) item;
    ElementInfo rootElementInfo = untypedItem.getRootElementInfo();
    boolean consider = true;
    switch(untypedItem.getState()) {
        case DELETED:
        case DELETE_REQUESTED:
            consider = false;
            break;
    }
    Set<String> instanceTypes = Sets.newHashSet();
    instanceTypes.add("directInstance");
    instanceTypes.add("googleCloudInstance");
    if (!instanceTypes.contains(rootElementInfo.elementName)) {
        consider = false;
    }
    if (consider) {
        Tags itemTags = untypedItem.getTags();
        for (InetAddress address : Tag.NETWORK_ADDRESS.find(itemTags)) {
            found.add(address);
        }
    }
    boolean includeDeleted = false;
    for (UntypedItem child : client.listChildren(untypedItem.getKey(), includeDeleted).getItems()) {
        visit(child);
    }
}
Also used : UntypedItem(org.platformlayer.common.UntypedItem) ElementInfo(org.platformlayer.xml.XmlHelper.ElementInfo) UntypedItemXml(org.platformlayer.UntypedItemXml) InetAddress(java.net.InetAddress) Tags(org.platformlayer.core.model.Tags)

Example 2 with ElementInfo

use of org.platformlayer.xml.XmlHelper.ElementInfo in project platformlayer by platformlayer.

the class TypedItemMapper method promoteToTyped.

public <T> T promoteToTyped(UntypedItem untypedItem) throws OpsException {
    ElementInfo elementInfo = ((UntypedItemXml) untypedItem).getRootElementInfo();
    Class<T> javaClass = mapToJavaClass(elementInfo);
    return promoteToTyped(untypedItem, javaClass);
}
Also used : ElementInfo(org.platformlayer.xml.XmlHelper.ElementInfo)

Example 3 with ElementInfo

use of org.platformlayer.xml.XmlHelper.ElementInfo in project platformlayer by platformlayer.

the class ServiceProviderDirectoryBase method getModelClass.

@Override
public <T extends ItemBase> ModelClass<T> getModelClass(Class<T> itemClass) {
    ModelClass<T> modelClass = javaClassToModelClass.get(itemClass);
    if (modelClass == null) {
        // Fallback to matching on XML info
        ElementInfo elementInfo = XmlHelper.getXmlElementInfo(itemClass);
        if (elementInfo != null) {
            ServiceProvider serviceProvider = serviceProvidersByNamespace.get(elementInfo.namespace);
            if (serviceProvider != null) {
                ItemType itemType = new ItemType(elementInfo.elementName);
                modelClass = (ModelClass<T>) serviceProvider.getModelClass(itemType);
            }
        }
    }
    return modelClass;
}
Also used : ElementInfo(org.platformlayer.xml.XmlHelper.ElementInfo) ItemType(org.platformlayer.ids.ItemType)

Aggregations

ElementInfo (org.platformlayer.xml.XmlHelper.ElementInfo)3 InetAddress (java.net.InetAddress)1 UntypedItemXml (org.platformlayer.UntypedItemXml)1 UntypedItem (org.platformlayer.common.UntypedItem)1 Tags (org.platformlayer.core.model.Tags)1 ItemType (org.platformlayer.ids.ItemType)1