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