use of org.platformlayer.common.UntypedItem in project platformlayer by platformlayer.
the class FederatedPlatformLayerClient method putItem.
// @Override
// public <T> T getItem(final Class<T> clazz, final PlatformLayerKey key) throws PlatformLayerClientException {
// MappedPlatformLayerKey mapped = mapToChild(key);
// T item = mapped.child.client.getItem(clazz, mapped.key);
// return mapped.child.setHost(item);
// }
// @Override
// public <T> T createItem(T item) throws PlatformLayerClientException {
// PlatformLayerKey key = toKey(item);
//
// MappedPlatformLayerKey mapped = mapToChildForCreate(key);
//
// T created = mapped.child.client.createItem(item);
// return mapped.child.setHost(created);
// }
//
// @Override
// public String createItem(ServiceType serviceType, ItemType itemType, String data, Format format) throws
// PlatformLayerClientException {
// throw new UnsupportedOperationException();
//
// // PlatformLayerKey key = new PlatformLayerKey(serviceType, itemType, null);
// // MappedPlatformLayerKey mapped = mapToChild(key);
// // String s = child.client.createItem(serviceType, itemType, data, format);
// // return child.setHost(s);
// }
@Override
public UntypedItem putItem(PlatformLayerKey key, String data, Format format) throws PlatformLayerClientException {
MappedPlatformLayerKey mapped = mapToChildForPut(key);
UntypedItemXml untypedItem = UntypedItemXml.build(data);
untypedItem.setPlatformLayerKey(mapped.key);
UntypedItem item = mapped.child.client.putItem(mapped.key, untypedItem.serialize(), format);
return mapped.child.setHost(item);
}
use of org.platformlayer.common.UntypedItem in project platformlayer by platformlayer.
the class DeleteTag method runCommand.
@Override
public Object runCommand() throws PlatformLayerClientException {
PlatformLayerClient client = getPlatformLayerClient();
PlatformLayerKey key = path.resolve(getContext());
UntypedItem ret = client.getItemUntyped(key, Format.XML);
TagChanges tagChanges = new TagChanges();
for (Tag tag : ret.getTags()) {
if (!tagKey.equals(tag.getKey())) {
continue;
}
if (tagValue != null && !tagValue.equals(tag.getValue())) {
continue;
}
tagChanges.removeTags.add(tag);
}
Tags newTags = client.changeTags(key, tagChanges, null);
return newTags;
}
use of org.platformlayer.common.UntypedItem in project platformlayer by platformlayer.
the class GetEndpoint method runCommand.
@Override
public Object runCommand() throws PlatformLayerClientException {
// Should this be a tag?
PlatformLayerClient client = getPlatformLayerClient();
PlatformLayerKey key = path.resolve(getContext());
UntypedItem untypedItem = client.getItemUntyped(key, Format.XML);
List<EndpointInfo> endpoints = EndpointInfo.getEndpoints(untypedItem.getTags());
return endpoints;
}
use of org.platformlayer.common.UntypedItem in project platformlayer by platformlayer.
the class HttpPlatformLayerClient method putItem.
@Override
public <T extends ItemBase> T putItem(T item) throws OpsException {
JaxbHelper jaxbHelper = PlatformLayerClientBase.toJaxbHelper(item);
String xml = PlatformLayerClientBase.serialize(jaxbHelper, item);
PlatformLayerKey key = PlatformLayerClientBase.toKey(jaxbHelper, item, listServices(true));
UntypedItem created = putItem(key, xml, Format.XML);
Class<T> itemClass = (Class<T>) item.getClass();
return promoteToTyped(created, itemClass);
}
use of org.platformlayer.common.UntypedItem in project platformlayer by platformlayer.
the class ListRoots method formatRaw.
@Override
public void formatRaw(Object o, PrintWriter writer) {
Ansi ansi = new Ansi(writer);
Iterable<UntypedItem> items = (Iterable<UntypedItem>) o;
for (UntypedItem item : items) {
UntypedItemFormatter.formatItem(item, ansi, true);
}
ansi.reset();
}
Aggregations