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);
}
}
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);
}
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;
}
Aggregations