Search in sources :

Example 1 with Link

use of org.platformlayer.core.model.Link in project platformlayer by platformlayer.

the class StandardTemplateData method getAdditionalKeys.

public void getAdditionalKeys(Map<String, ManagedSecretKey> keys) throws OpsException {
    for (Link link : getLinks()) {
        ItemBase item = platformLayer.getItem(link.getTarget());
        LinkTarget linkTarget = providers.toInterface(item, LinkTarget.class);
        PlatformLayerKey caPath = linkTarget.getCaForClientKey();
        if (caPath != null) {
            String alias = links.buildKeyName(link);
            keys.put(alias, findCaSignedKey(caPath, alias));
        }
    }
}
Also used : ItemBase(org.platformlayer.core.model.ItemBase) LinkTarget(org.platformlayer.ops.uses.LinkTarget) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) Link(org.platformlayer.core.model.Link)

Example 2 with Link

use of org.platformlayer.core.model.Link 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();
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) UntypedItemXml(org.platformlayer.UntypedItemXml) Links(org.platformlayer.core.model.Links) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) Link(org.platformlayer.core.model.Link)

Example 3 with Link

use of org.platformlayer.core.model.Link 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;
    }
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) UntypedItemXml(org.platformlayer.UntypedItemXml) Links(org.platformlayer.core.model.Links) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) Link(org.platformlayer.core.model.Link)

Example 4 with Link

use of org.platformlayer.core.model.Link in project platformlayer by platformlayer.

the class PlatformLayerInstanceTemplate method getLinks.

@Override
protected List<Link> getLinks() throws OpsException {
    List<Link> links = Lists.newArrayList();
    links.addAll(super.getLinks());
    {
        // Link to database
        Link link = new Link();
        link.name = "platformlayer";
        link.target = getDatabaseKey();
        links.add(link);
    }
    {
        // Link to user auth
        Link link = new Link();
        link.name = "auth.user";
        link.target = model.auth;
        links.add(link);
    }
    {
        // Link to system auth (token validation)
        Link link = new Link();
        link.name = "auth.system";
        link.target = model.systemAuth;
        links.add(link);
    }
    return links;
}
Also used : Link(org.platformlayer.core.model.Link)

Example 5 with Link

use of org.platformlayer.core.model.Link in project platformlayer by platformlayer.

the class CommonAuthTemplateData method getLinks.

@Override
protected List<Link> getLinks() throws OpsException {
    List<Link> links = Lists.newArrayList();
    links.addAll(super.getLinks());
    {
        Link link = new Link();
        link.name = "auth";
        link.target = getAuthDatabaseKey();
        links.add(link);
    }
    return links;
}
Also used : Link(org.platformlayer.core.model.Link)

Aggregations

Link (org.platformlayer.core.model.Link)7 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)3 PlatformLayerClient (org.platformlayer.PlatformLayerClient)2 UntypedItemXml (org.platformlayer.UntypedItemXml)2 ItemBase (org.platformlayer.core.model.ItemBase)2 Links (org.platformlayer.core.model.Links)2 InetAddressChooser (org.platformlayer.InetAddressChooser)1 NetworkPoint (org.platformlayer.ops.networks.NetworkPoint)1 LinkTarget (org.platformlayer.ops.uses.LinkTarget)1 SimpleLinkConsumer (org.platformlayer.ops.uses.SimpleLinkConsumer)1