Search in sources :

Example 6 with ItemBase

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

the class CollectdModelBuilder method getCollectdHostKey.

private String getCollectdHostKey() {
    // TODO: Multiple machines per service
    ItemBase managed = OpsContext.get().getInstance(ItemBase.class);
    PlatformLayerKey modelKey = managed.getKey();
    return CollectdHelpers.toCollectdKey(modelKey);
}
Also used : ItemBase(org.platformlayer.core.model.ItemBase) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey)

Example 7 with ItemBase

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

the class DatabaseController method buildLinkTargetConfiguration.

@Override
public Map<String, String> buildLinkTargetConfiguration(LinkConsumer consumer) throws OpsException {
    ItemBase serverItem = platformLayer.getItem(model.server);
    DatabaseServer databaseServer = providers.toInterface(serverItem, DatabaseServer.class);
    InetAddressChooser inetAddressChooser = consumer.getInetAddressChooser();
    return databaseServer.buildTargetConfiguration(model.username, model.password, model.databaseName, inetAddressChooser);
}
Also used : ItemBase(org.platformlayer.core.model.ItemBase) InetAddressChooser(org.platformlayer.InetAddressChooser) DatabaseServer(org.platformlayer.ops.databases.DatabaseServer)

Example 8 with ItemBase

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

the class JdbcManagedItemRepository method findRoots.

@Override
@JdbcTransaction
public List<ItemBase> findRoots(ProjectId project, boolean fetchTags, SecretProvider secretProvider) throws RepositoryException {
    DbHelper db = new DbHelper(project);
    try {
        // TODO: Push-down logic for item selection as well
        JoinedQueryResult result = db.listRoots();
        List<ItemBase> roots = mapItemsAndTags(project, secretProvider, db, result);
        for (ItemBase root : roots) {
            // A little bit of paranoia
            boolean isRoot = true;
            for (Tag tag : root.getTags()) {
                boolean tagIsParent = Tag.PARENT.getKey().equals(tag.getKey());
                if (tagIsParent) {
                    isRoot = false;
                    break;
                }
            }
            assert isRoot;
            if (!isRoot) {
                throw new IllegalStateException();
            }
        }
        return roots;
    } catch (SQLException e) {
        throw new RepositoryException("Error fetching items", e);
    } finally {
        db.close();
    }
}
Also used : ItemBase(org.platformlayer.core.model.ItemBase) SQLException(java.sql.SQLException) RepositoryException(org.platformlayer.RepositoryException) Tag(org.platformlayer.core.model.Tag) JoinedQueryResult(com.fathomdb.jpa.impl.JoinedQueryResult) JdbcTransaction(com.fathomdb.jdbc.JdbcTransaction)

Example 9 with ItemBase

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

the class ManagedItemResource method retrieveItem.

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

Example 10 with ItemBase

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

the class ManagedItemResource method getExtensionsResource.

@Path("extensions")
public Object getExtensionsResource() throws Exception {
    OpsContextBuilder opsContextBuilder = objectInjector.getInstance(OpsContextBuilder.class);
    final OpsContext opsContext = opsContextBuilder.buildTemporaryOpsContext(getServiceType(), getProjectAuthorization());
    Object extensionResource = OpsContext.runInContext(opsContext, new CheckedCallable<Object, Exception>() {

        @Override
        public Object call() throws Exception {
            boolean fetchTags = true;
            ItemBase managedItem = getManagedItem(fetchTags);
            ServiceProvider serviceProvider = getServiceProvider();
            Object resource = serviceProvider.getItemExtensionResource(managedItem);
            return resource;
        }
    });
    if (extensionResource == null) {
        raiseNotFound();
    }
    return extensionResource;
}
Also used : ItemBase(org.platformlayer.core.model.ItemBase) ServiceProvider(org.platformlayer.xaas.services.ServiceProvider) OpsContext(org.platformlayer.ops.OpsContext) RepositoryException(org.platformlayer.RepositoryException) OpsException(org.platformlayer.ops.OpsException) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException) OpsContextBuilder(org.platformlayer.ops.tasks.OpsContextBuilder) Path(javax.ws.rs.Path)

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