Search in sources :

Example 21 with ServiceType

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

the class InstanceHelpers method getTarget.

public OpsTarget getTarget(ItemBase item, Machine machine) throws OpsException {
    ServiceType serviceType = serviceProviders.getServiceType(item.getClass());
    // TODO: This is so evil...
    SshKey sshKey = sshKeys.findOtherServiceKey(serviceType);
    return machine.getTarget(sshKey);
}
Also used : ServiceType(org.platformlayer.ids.ServiceType)

Example 22 with ServiceType

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

the class ServiceProviderBase method resolveKey.

private PlatformLayerKey resolveKey(PlatformLayerKey key) throws OpsException {
    if (key.getServiceType() == null) {
        ItemType itemType = key.getItemType();
        ServiceType serviceType = OpsContext.get().getOpsSystem().getServiceType(itemType);
        key = key.withServiceType(serviceType);
    }
    if (key.getProject() == null) {
        key = key.withProject(OpsContext.get().getPlatformLayerClient().getProject());
    }
    return key;
}
Also used : ServiceType(org.platformlayer.ids.ServiceType) ItemType(org.platformlayer.ids.ItemType)

Example 23 with ServiceType

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

the class ManagedItemResource method checkItemKey.

private void checkItemKey(ItemBase item) throws OpsException {
    PlatformLayerKey key = item.getKey();
    ManagedItemId itemId = getItemId();
    ServiceType serviceType = getServiceType();
    ItemType itemType = getItemType();
    ProjectId project = getProject();
    if (key != null) {
        if (key.getItemId() != null && !equal(key.getItemId(), itemId)) {
            throw new OpsException("Item id mismatch");
        }
        if (key.getServiceType() != null && !equal(key.getServiceType(), serviceType)) {
            throw new OpsException("Service type mismatch");
        }
        if (key.getItemType() != null && !key.getItemType().isEmpty() && !equal(key.getItemType(), itemType)) {
            throw new OpsException("Item type mismatch");
        }
        if (key.getProject() != null && !equal(key.getProject(), project)) {
            throw new OpsException("Project mismatch");
        }
    }
    key = new PlatformLayerKey(null, project, serviceType, itemType, itemId);
    item.setKey(key);
}
Also used : OpsException(org.platformlayer.ops.OpsException) ServiceType(org.platformlayer.ids.ServiceType) ItemType(org.platformlayer.ids.ItemType) ProjectId(org.platformlayer.ids.ProjectId) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) ManagedItemId(org.platformlayer.ids.ManagedItemId)

Example 24 with ServiceType

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

the class ServiceAuthorizationResource method retrieveItem.

@GET
@Produces({ XML, JSON })
public ServiceAuthorization retrieveItem() throws RepositoryException {
    ServiceType serviceType = getServiceType();
    ServiceAuthorization auth = authorizationRepository.findServiceAuthorization(serviceType, getProject());
    if (auth == null) {
        throw new WebApplicationException(404);
    }
    // For security, never return the data
    auth.data = null;
    return auth;
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) ServiceType(org.platformlayer.ids.ServiceType) ServiceAuthorization(org.platformlayer.xaas.model.ServiceAuthorization) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

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