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