Hello everyone.
I am Paul Majchrowicz a PHP programmer who starts his adventure with Java from "API Java SDK for vCloud".
I have questions which propably are borned from my aknowlegnment of Java language .
I have to deploy new Vapp (create vApp from vAppTemplate which already exists in Catalog). I tried two ways.
1. Create initialize object ReferenceType tpl by with Catalog catalog object method getCatalogItemRefByName
ReferenceType tpl = catalog.getCatalogItemRefByName("HellovCloudvAppTemplate")
Here comes first of my questions. What is argument for method getCatalogItemRefByName ?
I've tried name taken directly from vcloud client panel (vcloud_client_panel.png), but in this case get null.
2. I try methods
Vdc vdc.getVappTemplateRefs()
Catalog catalog.getCatalogItemReferences()
I have non empty Collection set_vapp_tpls in return, but when i use method set_vapp_tpls.iterator().next() I get in return Object item and I don't know what can I do with this Object item. when I System.outprintln(item.toString()) I have such a result:
com.vmware.vcloud.api.rest.schema.ResourceReferenceType@5abe7eaa
Here comes my question. How Can I pick up ReferenceType vapp_tpl from such an object (Object item) ?
Regards
Paul Majchrowicz
Hi,
1. The argument you're passing to getCatalogItemRefByName() is correct. Can you make sure that the 'catalog' object you're using points to the right catalog (named 'pmaj') containing the catalog item.
2. Both methods return Collections of ReferenceType objects. You can just cast the Object that you get to ReferenceType or you can use the shorter variant (taken from the SDK samples which are available on the website):
Collection<ReferenceType> vAppTemplateReferences = vdc.getVappTemplateRefs();
Regards,
Todor Todorov
Hello,
Thank You for answer - Your solution was vary helpful, but I still have some doubts.
Now I know, that sentence:
ReferenceType cat_item = catalog.getCatalogItemRefByName("HellovCloudvAppTemplate");
still doesn't work, but... If I 've written something like this:
, and I have such an output:
HelloVcloudCatalog1 Description
https://[domain]/api/catalogItem/95ece2e9-2f6f-4466-862b-cd48e155e211.
I have question. Is there any possibility to acquire VappTemplate vapp_tpl from ReferenceType cat_item_ref ?
I think this catalog_item should be vapp_tpl, but it's
I have such a structure of Catalogs in panel administrator -- attachment catalogs.png
Hi,
If you have a ReferenceType pointing to a catalog item, for example cat_item_ref, you can do the following:
CatalogItem catItem = CatalogItem.getCatalogItemByReference(vcloudClient, cat_item_ref);
VappTemplate template = VappTemplate.getVappTemplateByReference(vcloudClient, catItem.getEntityReference());
The catalog item is basically a reference to a vApp template or Media object. This reference can be retrieved by calling catItem.getEntityReference()..
Probably it's easier to deal with vApp templates directly by using methods like vdc.getVappTemplateRefs() mentioned in your first post..
Regards,
Todor Todorov