It's all about the answers!

Ask a question

Getting around AssetNotFoundException using Java API


Sanjay Karnam (4134) | asked Jan 17 '12, 1:58 p.m.
We are trying to load assets into RAM using Java API. As we load them into RAM we store the GUID for the asset in a Map in the Java program. When a new asset needs to be associated (related) to this asset then we retrieve the GUID from the Map for the asset, get the asset from session and then refresh the asset using asset.refresh() method on the API (to get the latest version of the asset). We then make a relationship between the new asset and the asset from the Map. But we are getting an com.ibm.ram.common.data.exception.AssetNotFoundException error when we retrieve the GUID for the asset from Map and get the latest version of the asset from the Session. Any ideas why the Asset cannot be found on the session?

3 answers



permanent link
Rich Kulp (3.6k38) | answered Jan 17 '12, 3:08 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
GUID is not sufficient to identify a particular asset. You need the
version too. When you say "get latest version" do you mean get the
current asset with that particular GUID and version? refrestAsset() does
not look for the latest version, it just refreshes the asset itself, it
won't get one of a different higher version.

So a little more detail would be useful:

a) Exactly what do you have stored in the map as key and value?

b) Exactly what code do you use when you say "When a new asset needs to
be associated (related) to this
asset then we retrieve the GUID from the Map for the asset, get the
asset from session and then refresh the asset using asset.refresh()
method on the API (to get the latest version of the asset)."


--
Rich Kulp
Rational Asset Manager developer

permanent link
Sanjay Karnam (4134) | answered Jan 17 '12, 5:06 p.m.
Richard, Thanks for the quick reply! We were told by a Rational Developer in one of the calls with us that we cannot search for an asset immediately after creating it. So we store its guid in a map (service name as key and guid as value in the map) and retrieve the asset from session using that guid when we need that asset. The assumption is that if the key (GUID) is found in the map then the asset was already created in RAM and we can get a handle to that asset using the guid so that we can create relationships between this asset and new assets. Now we are not sure if that asset is retrieved from server at that point when we do session.getAsset(guid) or its obtained from server after we do the refresh() method. We just need that asset so we can relate it to the other assets.We don't have multiple versions of the asset, RAM Java API documentation said something about versions on the AssetNotFoundException and that's what I was quoting. Not sure if that's enough info. If not I can email you the code if you need it. Thanks,

Sanjay Karnam


GUID is not sufficient to identify a particular asset. You need the
version too. When you say "get latest version" do you mean get the
current asset with that particular GUID and version? refrestAsset() does
not look for the latest version, it just refreshes the asset itself, it
won't get one of a different higher version.

So a little more detail would be useful:

a) Exactly what do you have stored in the map as key and value?

b) Exactly what code do you use when you say "When a new asset needs to
be associated (related) to this
asset then we retrieve the GUID from the Map for the asset, get the
asset from session and then refresh the asset using asset.refresh()
method on the API (to get the latest version of the asset)."


--
Rich Kulp
Rational Asset Manager developer

permanent link
Rich Kulp (3.6k38) | answered Jan 17 '12, 7:53 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
Hi,

If you just created it you can get its AssetIdentification instance and
put that in the map instead of GUID. This bypasses the search and the
indexer completely. Since directly upon submit (after waiting for the
submit to complete) it is guaranteed that the asset exists and the
AssetIdentification WILL find it.

Also, as I said GUID is not sufficient, even if you waited for the
indexer to finish. An asset IS NOT identified by GUID. It is identified
by GUID and Version (which is what the AssetIdentification wrappers up
for you).

The RAMClient's RAMAsset.getIdentification() will return the correct
identification immediately after submit. This will be able to find it in
the future even if the index has not yet been updated. You will use
RAMSession.getAsset(AssetIdentification) to get the asset.

RAMSession.getAsset(String guid) is obsolete and deprecated and should
not be used anymore.

--
Rich Kulp
Rational Asset Manager developer

Your answer


Register or to post your answer.