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