Search in sources :

Example 6 with FederationKey

use of org.platformlayer.ids.FederationKey in project platformlayer by platformlayer.

the class PlatformLayerClientBase method toKey.

public static <T> PlatformLayerKey toKey(JaxbHelper jaxbHelper, ManagedItemId id, Class<T> itemClass, Collection<ServiceInfo> services) throws PlatformLayerClientException {
    String namespaceURI = jaxbHelper.getPrimaryNamespace();
    String nodeName = jaxbHelper.getXmlElementName();
    if (namespaceURI == null) {
        throw new IllegalArgumentException("Namespace could not be determined");
    }
    ServiceInfo service = getServiceInfo(services, namespaceURI);
    if (service == null) {
        throw new PlatformLayerClientException("Cannot find service for " + namespaceURI);
    }
    ServiceType serviceType = new ServiceType(service.getServiceType());
    ItemType itemType = new ItemType(nodeName);
    FederationKey host = null;
    ProjectId project = null;
    return new PlatformLayerKey(host, project, serviceType, itemType, id);
}
Also used : ServiceInfo(org.platformlayer.core.model.ServiceInfo) ServiceType(org.platformlayer.ids.ServiceType) ItemType(org.platformlayer.ids.ItemType) ProjectId(org.platformlayer.ids.ProjectId) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) FederationKey(org.platformlayer.ids.FederationKey)

Example 7 with FederationKey

use of org.platformlayer.ids.FederationKey in project platformlayer by platformlayer.

the class PlatformLayerCommandRunnerBase method pathToKey.

public static PlatformLayerKey pathToKey(PlatformLayerClient client, String path) throws PlatformLayerClientException {
    String serviceType;
    String itemType;
    if (path.contains("/")) {
        String[] components = path.split("/");
        if (components.length != 2) {
            throw new IllegalArgumentException("Cannot parse path: " + path);
        }
        serviceType = components[0];
        itemType = components[1];
    } else {
        itemType = path;
        serviceType = getServiceTypeFromItemType(client, itemType);
    }
    FederationKey host = null;
    ProjectId project = client.getProject();
    return new PlatformLayerKey(host, project, new ServiceType(serviceType), new ItemType(itemType), null);
}
Also used : ServiceType(org.platformlayer.ids.ServiceType) ItemType(org.platformlayer.ids.ItemType) ProjectId(org.platformlayer.ids.ProjectId) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) FederationKey(org.platformlayer.ids.FederationKey)

Example 8 with FederationKey

use of org.platformlayer.ids.FederationKey in project platformlayer by platformlayer.

the class FederatedPlatformLayerClient method mapToChild.

private MappedPlatformLayerKey mapToChild(PlatformLayerKey plk) {
    // if (plk.getHost() != null) {
    //
    // }
    ManagedItemId itemId = plk.getItemId();
    if (itemId == null || itemId.isEmpty()) {
        throw new IllegalArgumentException();
    }
    FederationKey host = plk.getHost();
    if (host == null) {
        host = FederationKey.LOCAL;
    }
    ProjectId project = plk.getProject();
    if (project == null) {
        project = defaultProject;
    // project = federationMap.getLocalClient().getProject();
    }
    ChildClient childClient = getClient(new FederationMapping(host, project));
    MappedPlatformLayerKey mapped = new MappedPlatformLayerKey();
    mapped.child = childClient;
    mapped.key = new PlatformLayerKey(host, project, plk.getServiceType(), plk.getItemType(), plk.getItemId());
    return mapped;
// Iterable<ChildClient> childClients = getChildClients(plk);
// ChildClient client = null;
// for (ChildClient childClient : childClients) {
// if (client == null) {
// client = childClient;
// } else {
// throw new IllegalStateException("Multiple clients found");
// }
// }
// return client;
}
Also used : ProjectId(org.platformlayer.ids.ProjectId) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) ManagedItemId(org.platformlayer.ids.ManagedItemId) FederationKey(org.platformlayer.ids.FederationKey)

Example 9 with FederationKey

use of org.platformlayer.ids.FederationKey in project platformlayer by platformlayer.

the class FederationMap method addDefault.

public void addDefault(TypedPlatformLayerClient defaultClient) {
    FederationKey host = FederationKey.LOCAL;
    ProjectId project = defaultClient.getProject();
    FederationMapping mapKey = new FederationMapping(host, project);
    MappedTarget target = new MappedTarget();
    target.client = defaultClient;
    addMapping(mapKey, target);
}
Also used : ProjectId(org.platformlayer.ids.ProjectId) FederationKey(org.platformlayer.ids.FederationKey)

Example 10 with FederationKey

use of org.platformlayer.ids.FederationKey in project platformlayer by platformlayer.

the class FederationMap method buildRules.

private void buildRules(FederationConfiguration config) {
    for (FederationRule federationRule : config.rules) {
        Rule rule = new Rule();
        rule.mappedItems = PlatformLayerKey.fromServiceAndItem(federationRule.serviceType, null);
        for (PlatformLayerConnectionConfiguration system : config.systems) {
            if (Objects.equal(system.key, federationRule.target)) {
                if (rule.targetKey != null) {
                    throw new IllegalStateException();
                }
                FederationKey host = FederationKey.build(system.authenticationEndpoint);
                ProjectId project = new ProjectId(system.tenant);
                rule.targetKey = new FederationMapping(host, project);
            }
        }
        if (rule.targetKey == null) {
            throw new IllegalStateException();
        }
        addRule(rule);
    }
}
Also used : FederationRule(org.platformlayer.federation.model.FederationRule) PlatformLayerConnectionConfiguration(org.platformlayer.federation.model.PlatformLayerConnectionConfiguration) ProjectId(org.platformlayer.ids.ProjectId) FederationRule(org.platformlayer.federation.model.FederationRule) FederationKey(org.platformlayer.ids.FederationKey)

Aggregations

FederationKey (org.platformlayer.ids.FederationKey)12 ProjectId (org.platformlayer.ids.ProjectId)11 ServiceType (org.platformlayer.ids.ServiceType)6 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)5 ItemType (org.platformlayer.ids.ItemType)5 ManagedItemId (org.platformlayer.ids.ManagedItemId)4 ServiceInfo (org.platformlayer.core.model.ServiceInfo)2 PlatformLayerConnectionConfiguration (org.platformlayer.federation.model.PlatformLayerConnectionConfiguration)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Map (java.util.Map)1 PlatformLayerClient (org.platformlayer.PlatformLayerClient)1 RepositoryException (org.platformlayer.RepositoryException)1 TypedPlatformLayerClient (org.platformlayer.TypedPlatformLayerClient)1 FederatedPlatformLayerClient (org.platformlayer.federation.FederatedPlatformLayerClient)1 FederationMap (org.platformlayer.federation.FederationMap)1 FederationMapping (org.platformlayer.federation.FederationMapping)1 FederationConfiguration (org.platformlayer.federation.model.FederationConfiguration)1 FederationRule (org.platformlayer.federation.model.FederationRule)1 ProjectAuthorization (org.platformlayer.model.ProjectAuthorization)1