use of org.platformlayer.ids.ServiceType in project platformlayer by platformlayer.
the class PlatformLayerKey method build.
public static PlatformLayerKey build(String host, String project, String serviceType, String itemType, String itemId) {
FederationKey federationKey = host != null ? FederationKey.build(host) : null;
ProjectId projectKey = project != null ? new ProjectId(project) : null;
ServiceType serviceKey = serviceType != null ? new ServiceType(serviceType) : null;
ItemType itemKey = itemType != null ? new ItemType(itemType) : null;
ManagedItemId idKey = itemId != null ? new ManagedItemId(itemId) : null;
return new PlatformLayerKey(federationKey, projectKey, serviceKey, itemKey, idKey);
}
use of org.platformlayer.ids.ServiceType in project platformlayer by platformlayer.
the class JaxbContextHelper method getJaxbContext.
public synchronized JAXBContext getJaxbContext(Class<?> forClass) {
if (jaxbContext == null) {
List<Class<?>> javaClasses = Lists.newArrayList();
javaClasses.add(Tags.class);
javaClasses.add(Tag.class);
javaClasses.add(ItemBase.class);
javaClasses.add(ManagedItemCollection.class);
javaClasses.add(JobSchedule.class);
javaClasses.add(PlatformLayerKey.class);
javaClasses.add(ConfigureAction.class);
javaClasses.add(ValidateAction.class);
javaClasses.add(DeleteAction.class);
javaClasses.add(BackupAction.class);
for (ServiceInfo serviceInfo : serviceProviderDictionary.getAllServices()) {
ServiceType serviceType = new ServiceType(serviceInfo.serviceType);
ServiceProvider serviceProvider = serviceProviderDictionary.getServiceProvider(serviceType);
for (ModelClass<?> modelClass : serviceProvider.getModels().all()) {
javaClasses.add(modelClass.getJavaClass());
// String modelNamespace = modelClass.getJaxbHelper().getPrimaryNamespace();
// if (namespace == null) {
// namespace = modelNamespace;
// } else if (!namespace.equals(modelNamespace)) {
// throw new IllegalStateException();
// }
}
for (Class<?> clazz : serviceProvider.getActions()) {
javaClasses.add(clazz);
}
}
try {
jaxbContext = JAXBContext.newInstance(javaClasses.toArray(new Class<?>[javaClasses.size()]));
} catch (JAXBException e) {
throw new IllegalStateException("Unable to build JAXB context", e);
}
}
return jaxbContext;
}
use of org.platformlayer.ids.ServiceType in project platformlayer by platformlayer.
the class ServiceProviderHelpers method getModelSubclasses.
public <T extends ItemBase> List<ModelClass<? extends T>> getModelSubclasses(Class<T> parent) {
List<ModelClass<? extends T>> modelClasses = Lists.newArrayList();
for (ServiceInfo serviceInfo : serviceProviderDictionary.getAllServices()) {
ServiceType serviceType = new ServiceType(serviceInfo.serviceType);
ServiceProvider serviceProvider = serviceProviderDictionary.getServiceProvider(serviceType);
for (ModelClass<?> modelClass : serviceProvider.getModels().all()) {
Class<?> javaClass = modelClass.getJavaClass();
if (parent.isAssignableFrom(javaClass)) {
modelClasses.add((ModelClass<? extends T>) modelClass);
}
}
}
return modelClasses;
}
use of org.platformlayer.ids.ServiceType in project platformlayer by platformlayer.
the class PlatformLayerKey method parse.
public static PlatformLayerKey parse(String s) {
if (!s.contains("://")) {
int slashCount = 0;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '/') {
slashCount++;
}
}
String extraSlashes = "";
if (slashCount < 4) {
extraSlashes = Strings.repeat("/", 4 - slashCount);
}
s = SCHEME + "://" + extraSlashes + s;
}
URI uri;
try {
uri = new URI(s);
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Error parsing URI", e);
}
if (!Objects.equal(SCHEME, uri.getScheme())) {
throw new IllegalArgumentException();
}
FederationKey hostKey = null;
String host = uri.getHost();
if (!Strings.isNullOrEmpty(host)) {
hostKey = FederationKey.build(host);
}
String path = uri.getPath();
if (path.startsWith("/")) {
path = path.substring(1);
}
ArrayList<String> components = Lists.newArrayList(Splitter.on('/').split(path));
if (components.size() < 4) {
throw new IllegalArgumentException();
}
String componentProject = components.get(0);
ProjectId project = !Strings.isNullOrEmpty(componentProject) ? new ProjectId(componentProject) : null;
String serviceComponent = components.get(1);
ServiceType serviceType = !Strings.isNullOrEmpty(serviceComponent) ? new ServiceType(serviceComponent) : null;
ItemType itemType = new ItemType(components.get(2));
ManagedItemId itemId = new ManagedItemId(Joiner.on("/").join(components.subList(3, components.size())));
return new PlatformLayerKey(hostKey, project, serviceType, itemType, itemId);
}
use of org.platformlayer.ids.ServiceType in project platformlayer by platformlayer.
the class DirectHostController method getCasStore.
@Override
public CasStore getCasStore() throws OpsException {
// TODO: Getting the IP like this is evil
NetworkPoint targetAddress;
// if (host.getIpv6() != null) {
// IpRange ipv6Range = IpV6Range.parse(host.getIpv6());
// targetAddress = NetworkPoint.forPublicHostname(ipv6Range.getGatewayAddress());
// } else {
targetAddress = NetworkPoint.forPublicHostname(model.host);
// }
Machine machine = new OpaqueMachine(targetAddress);
OpsTarget machineTarget = machine.getTarget(sshKeys.findOtherServiceKey(new ServiceType("machines-direct")));
CasStoreInfo casStoreOptions = new CasStoreInfo(true);
FilesystemCasStore store = new FilesystemCasStore(casStoreOptions, new OpsCasTarget(machineTarget));
return store;
}
Aggregations