use of org.platformlayer.core.model.Links in project platformlayer by platformlayer.
the class PutLink method runCommand.
@Override
public Object runCommand() throws PlatformLayerClientException {
PlatformLayerClient client = getPlatformLayerClient();
PlatformLayerKey resolved = path.resolve(getContext());
UntypedItemXml item = (UntypedItemXml) client.getItemUntyped(resolved, Format.XML);
Links links = item.getLinks();
Link link = new Link();
link.name = name;
link.target = target.resolve(getContext());
Link existing = links.findLink(name);
List<Link> linkList = links.getLinks();
if (existing != null) {
linkList.remove(existing);
}
linkList.add(link);
item.setLinks(links);
String xml = item.serialize();
UntypedItemXml updated = (UntypedItemXml) client.putItem(resolved, xml, Format.XML);
return updated.getLinks().getLinks();
}
use of org.platformlayer.core.model.Links in project platformlayer by platformlayer.
the class DeleteLink method runCommand.
@Override
public Object runCommand() throws PlatformLayerClientException {
PlatformLayerClient client = getPlatformLayerClient();
PlatformLayerKey resolved = path.resolve(getContext());
UntypedItemXml item = (UntypedItemXml) client.getItemUntyped(resolved, Format.XML);
Links links = item.getLinks();
Link existing = links.findLink(name);
List<Link> linkList = links.getLinks();
if (existing != null) {
linkList.remove(existing);
item.setLinks(links);
String xml = item.serialize();
UntypedItemXml updated = (UntypedItemXml) client.putItem(resolved, xml, Format.XML);
return updated.getLinks().getLinks();
} else {
return linkList;
}
}
Aggregations