Search in sources :

Example 11 with ItemBase

use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.

the class MetricsResource method listMetrics.

@GET
@Produces({ XML, JSON })
public MetricInfoCollection listMetrics() throws OpsException, RepositoryException {
    final ItemBase managedItem = getManagedItem();
    final ServiceProvider serviceProvider = getServiceProvider();
    OpsContextBuilder opsContextBuilder = objectInjector.getInstance(OpsContextBuilder.class);
    final OpsContext opsContext = opsContextBuilder.buildTemporaryOpsContext(getServiceType(), getProjectAuthorization());
    return OpsContext.runInContext(opsContext, new CheckedCallable<MetricInfoCollection, Exception>() {

        @Override
        public MetricInfoCollection call() throws Exception {
            BindingScope bindingScope = BindingScope.push(managedItem, managedItem);
            try {
                Object controller = serviceProvider.getController(managedItem);
                MetricConfig metricConfig = opsContext.getMetricInfo(controller);
                return MetricCollector.toMetricInfo(metricConfig);
            } finally {
                bindingScope.pop();
            }
        }
    });
}
Also used : MetricConfig(org.platformlayer.ops.model.metrics.MetricConfig) ItemBase(org.platformlayer.core.model.ItemBase) ServiceProvider(org.platformlayer.xaas.services.ServiceProvider) MetricInfoCollection(org.platformlayer.metrics.model.MetricInfoCollection) OpsContext(org.platformlayer.ops.OpsContext) RepositoryException(org.platformlayer.RepositoryException) OpsException(org.platformlayer.ops.OpsException) OpsContextBuilder(org.platformlayer.ops.tasks.OpsContextBuilder) BindingScope(org.platformlayer.ops.BindingScope) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 12 with ItemBase

use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.

the class ItemServiceImpl method findRoots.

@Override
public List<ItemBase> findRoots(ProjectAuthorization authentication) throws OpsException {
    ProjectId project = getProjectId(authentication);
    boolean fetchTags = true;
    List<ItemBase> items;
    try {
        items = repository.findRoots(project, fetchTags, SecretProvider.from(authentication));
    } catch (RepositoryException e) {
        throw new OpsException("Error reading objects from database", e);
    }
    return items;
}
Also used : OpsException(org.platformlayer.ops.OpsException) ItemBase(org.platformlayer.core.model.ItemBase) ProjectId(org.platformlayer.ids.ProjectId) RepositoryException(org.platformlayer.RepositoryException)

Example 13 with ItemBase

use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.

the class ItemServiceImpl method listAll.

@Override
public List<ItemBase> listAll(ProjectAuthorization authentication, Filter filter) throws OpsException {
    ProjectId project = getProjectId(authentication);
    List<ItemBase> items;
    try {
        items = repository.listAll(project, filter, SecretProvider.from(authentication));
    } catch (RepositoryException e) {
        throw new OpsException("Error reading objects from database", e);
    }
    return items;
}
Also used : OpsException(org.platformlayer.ops.OpsException) ItemBase(org.platformlayer.core.model.ItemBase) ProjectId(org.platformlayer.ids.ProjectId) RepositoryException(org.platformlayer.RepositoryException)

Example 14 with ItemBase

use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.

the class TagsResource method listTags.

@GET
@Produces({ XML, JSON })
public Tags listTags() throws RepositoryException {
    boolean fetchTags = true;
    ItemBase managedItem = getManagedItem(fetchTags);
    Tags tags = managedItem.getTags();
    cleanup(tags);
    return tags;
}
Also used : ItemBase(org.platformlayer.core.model.ItemBase) Tags(org.platformlayer.core.model.Tags) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 15 with ItemBase

use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.

the class XaasResourceBase method getManagedItem.

protected ItemBase getManagedItem(boolean fetchTags) throws RepositoryException {
    PlatformLayerKey modelKey = getPlatformLayerKey();
    ItemBase managedItem = repository.getManagedItem(modelKey, fetchTags, getSecretProvider());
    if (managedItem == null) {
        raiseNotFound();
    }
    return managedItem;
}
Also used : ItemBase(org.platformlayer.core.model.ItemBase) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey)

Aggregations

ItemBase (org.platformlayer.core.model.ItemBase)56 OpsException (org.platformlayer.ops.OpsException)20 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)14 RepositoryException (org.platformlayer.RepositoryException)11 OpsContext (org.platformlayer.ops.OpsContext)11 Tag (org.platformlayer.core.model.Tag)8 BindingScope (org.platformlayer.ops.BindingScope)7 Machine (org.platformlayer.ops.Machine)7 DatabaseServer (org.platformlayer.ops.databases.DatabaseServer)6 ServiceProvider (org.platformlayer.xaas.services.ServiceProvider)6 Produces (javax.ws.rs.Produces)5 List (java.util.List)4 GET (javax.ws.rs.GET)4 TagChanges (org.platformlayer.core.model.TagChanges)4 OpsTarget (org.platformlayer.ops.OpsTarget)4 NetworkPoint (org.platformlayer.ops.networks.NetworkPoint)4 JAXBException (javax.xml.bind.JAXBException)3 Filter (org.platformlayer.Filter)3 InetAddressChooser (org.platformlayer.InetAddressChooser)3 StateFilter (org.platformlayer.StateFilter)3