use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.
the class DirectPlatformLayerClient method findItem.
@Override
public <T> T findItem(PlatformLayerKey key) throws PlatformLayerClientException {
key = resolveKey(key);
boolean fetchTags = true;
ItemBase managedItem;
try {
managedItem = itemRepository.getManagedItem(key, fetchTags, getSecretProvider());
} catch (RepositoryException e) {
throw new PlatformLayerClientException("Error fetching item", e);
}
return (T) managedItem;
}
use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.
the class DirectPlatformLayerClient method listChildrenTyped.
@Override
public List<ItemBase> listChildrenTyped(PlatformLayerKey parentKey, boolean includeDeleted) throws OpsException {
parentKey = resolveKey(parentKey);
Tag parentTag = Tag.buildParentTag(parentKey);
Filter filter = TagFilter.byTag(parentTag);
if (!includeDeleted) {
filter = StateFilter.excludeDeleted(filter);
}
List<ItemBase> items = itemService.listAll(auth, filter);
return items;
}
use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.
the class UntypedItemXml method setLinks.
public void setLinks(Links links) {
ItemBase item = new ItemBase();
item.links = links;
Document document;
JaxbHelper helper = JaxbHelper.get(ItemBase.class);
try {
document = helper.marshalToDom(item);
} catch (JAXBException e) {
throw new IllegalStateException("Error serializing data", e);
}
replaceNode("links", XmlHelper.findUniqueChild(document.getDocumentElement(), "links", false));
// To avoid any possible state problems, we set to null rather than copying
this.links = null;
}
use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.
the class PlatformlayerBackedPool method release.
@Override
public void release(PlatformLayerKey owner, T item) throws OpsException {
for (int i = 0; i < 10; i++) {
ItemBase resource = platformLayer.getItem(resourceKey);
List<Assignment> assignments = findAssignments(resource);
String key = adapter.toKey(item);
Assignment assigned = Assignment.find(assignments, key, subkey);
if (assigned == null) {
throw new OpsException("Resource not assigned");
}
if (!assigned.item.equals(owner.getUrl())) {
throw new OpsException("Resource not held");
}
Tag assignmentTag = assigned.asTag();
TagChanges tagChanges = new TagChanges();
tagChanges.removeTags.add(assignmentTag);
if (null != platformLayer.changeTags(resourceKey, tagChanges, resource.getVersion())) {
return;
}
if (!TimeSpan.ONE_SECOND.doSafeSleep()) {
break;
}
}
// List<PlatformLayerKey> assignedTo = Tag.POOL_ASSIGNMENT.build(t) Tag.ASSIGNED_TO.find(item);
// if (!assignedTo.contains(holder)) {
// throw new OpsException("Resource not owned");
// }
//
// platformLayer.deleteItem(item.getKey());
}
use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.
the class StandardTemplateData method getAdditionalKeys.
public void getAdditionalKeys(Map<String, ManagedSecretKey> keys) throws OpsException {
for (Link link : getLinks()) {
ItemBase item = platformLayer.getItem(link.getTarget());
LinkTarget linkTarget = providers.toInterface(item, LinkTarget.class);
PlatformLayerKey caPath = linkTarget.getCaForClientKey();
if (caPath != null) {
String alias = links.buildKeyName(link);
keys.put(alias, findCaSignedKey(caPath, alias));
}
}
}
Aggregations