Search in sources :

Example 31 with ProjectId

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

the class FederationMap method buildDefault.

private FederationMapping buildDefault(PlatformLayerKey original) {
    FederationKey targetHost = original.getHost();
    if (targetHost == null) {
        targetHost = FederationKey.LOCAL;
    }
    ProjectId targetProject = original.getProject();
    return new FederationMapping(targetHost, targetProject);
}
Also used : ProjectId(org.platformlayer.ids.ProjectId) FederationKey(org.platformlayer.ids.FederationKey)

Example 32 with ProjectId

use of org.platformlayer.ids.ProjectId 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 33 with ProjectId

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

the class RootResource method retrieveServiceList.

@Path("{projectId}")
public ServicesCollectionResource retrieveServiceList(@PathParam("projectId") String projectKey) {
    ProjectAuthorization authz = AuthenticationFilter.authorizeProject(getAuthenticationCredentials(), authTokenValidator, projectKey);
    if (authz == null) {
        throw new WebApplicationException(HttpServletResponse.SC_UNAUTHORIZED);
    }
    List<RoleId> roles = authz.getRoles();
    if (roles == null || !roles.contains(RoleId.OWNER)) {
        throw new WebApplicationException(HttpServletResponse.SC_UNAUTHORIZED);
    }
    // Note that we have a different notion of project id from the auth system
    // TODO: I think this is not needed for direct authentication? Fix? Cleanup?
    authz = new XaasProjectAuthorization(repository, authz);
    getScope().put(new ProjectId(projectKey));
    getScope().put(ProjectAuthorization.class, authz);
    ServicesCollectionResource resources = objectInjector.getInstance(ServicesCollectionResource.class);
    return resources;
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) ProjectAuthorization(org.platformlayer.model.ProjectAuthorization) ProjectId(org.platformlayer.ids.ProjectId) RoleId(org.platformlayer.model.RoleId) Path(javax.ws.rs.Path)

Aggregations

ProjectId (org.platformlayer.ids.ProjectId)33 RepositoryException (org.platformlayer.RepositoryException)14 FederationKey (org.platformlayer.ids.FederationKey)11 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)10 ManagedItemId (org.platformlayer.ids.ManagedItemId)9 OpsException (org.platformlayer.ops.OpsException)8 JdbcTransaction (com.fathomdb.jdbc.JdbcTransaction)7 SQLException (java.sql.SQLException)7 ServiceType (org.platformlayer.ids.ServiceType)7 ItemType (org.platformlayer.ids.ItemType)6 ProjectAuthorization (org.platformlayer.model.ProjectAuthorization)4 PlatformLayerClient (org.platformlayer.PlatformLayerClient)3 ItemBase (org.platformlayer.core.model.ItemBase)3 JobData (org.platformlayer.jobs.model.JobData)3 TypedPlatformLayerClient (org.platformlayer.TypedPlatformLayerClient)2 Authenticator (org.platformlayer.auth.Authenticator)2 DirectAuthenticator (org.platformlayer.auth.DirectAuthenticator)2 FederatedPlatformLayerClient (org.platformlayer.federation.FederatedPlatformLayerClient)2 PlatformLayerConnectionConfiguration (org.platformlayer.federation.model.PlatformLayerConnectionConfiguration)2 DirectPlatformLayerClient (org.platformlayer.ops.DirectPlatformLayerClient)2