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