Search in sources :

Example 16 with ServiceType

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);
}
Also used : ServiceType(org.platformlayer.ids.ServiceType) ItemType(org.platformlayer.ids.ItemType) ProjectId(org.platformlayer.ids.ProjectId) ManagedItemId(org.platformlayer.ids.ManagedItemId) FederationKey(org.platformlayer.ids.FederationKey)

Example 17 with ServiceType

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;
}
Also used : ServiceInfo(org.platformlayer.core.model.ServiceInfo) ServiceType(org.platformlayer.ids.ServiceType) ServiceProvider(org.platformlayer.xaas.services.ServiceProvider) JAXBException(javax.xml.bind.JAXBException) ModelClass(org.platformlayer.xaas.services.ModelClass)

Example 18 with ServiceType

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;
}
Also used : ServiceInfo(org.platformlayer.core.model.ServiceInfo) ModelClass(org.platformlayer.xaas.services.ModelClass) ServiceType(org.platformlayer.ids.ServiceType) ServiceProvider(org.platformlayer.xaas.services.ServiceProvider)

Example 19 with ServiceType

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);
}
Also used : ItemType(org.platformlayer.ids.ItemType) ProjectId(org.platformlayer.ids.ProjectId) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) ManagedItemId(org.platformlayer.ids.ManagedItemId) FederationKey(org.platformlayer.ids.FederationKey) ServiceType(org.platformlayer.ids.ServiceType)

Example 20 with ServiceType

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;
}
Also used : CasStoreInfo(org.platformlayer.cas.CasStoreInfo) OpsTarget(org.platformlayer.ops.OpsTarget) FilesystemCasStore(org.platformlayer.ops.cas.filesystem.FilesystemCasStore) ServiceType(org.platformlayer.ids.ServiceType) OpaqueMachine(org.platformlayer.ops.OpaqueMachine) OpsCasTarget(org.platformlayer.ops.cas.OpsCasTarget) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint) Machine(org.platformlayer.ops.Machine) OpaqueMachine(org.platformlayer.ops.OpaqueMachine)

Aggregations

ServiceType (org.platformlayer.ids.ServiceType)24 ItemType (org.platformlayer.ids.ItemType)10 ProjectId (org.platformlayer.ids.ProjectId)7 ServiceProvider (org.platformlayer.xaas.services.ServiceProvider)7 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)6 ServiceInfo (org.platformlayer.core.model.ServiceInfo)6 FederationKey (org.platformlayer.ids.FederationKey)6 ManagedItemId (org.platformlayer.ids.ManagedItemId)5 RepositoryException (org.platformlayer.RepositoryException)4 OpsException (org.platformlayer.ops.OpsException)4 WebApplicationException (javax.ws.rs.WebApplicationException)3 OpsContext (org.platformlayer.ops.OpsContext)3 ServiceAuthorization (org.platformlayer.xaas.model.ServiceAuthorization)3 JdbcTransaction (com.fathomdb.jdbc.JdbcTransaction)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 SQLException (java.sql.SQLException)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 JAXBException (javax.xml.bind.JAXBException)2