Working with 7.5.1.1 RAM java api. RAMLibrary is returning null.
Friends,
I decided to write some custom code to draw out the RAMAttribures and RAMLibrary. We are using RAM 7.5.1.1 with the ifix pack 6.
The code to extract RAMAttributes is working great.
Active code:
public class RamJavaClient implements IAttribute {
private RAMAsset ramAsset;
private RAMSession session;
// private RAMLibrary ramLibary;
public RamJavaClient(String RamServerConnection, String user, String passwd) {
this.session = new RAMSession(RamServerConnection, user, passwd);
}
public RAMAsset getRamAsset() {
return ramAsset;
}
public RAMSession getSession() {
return session;
}
/*
* public RAMLibrary getLibrary() { return ramLibary; }
*
* public void setRamLibrary(String sessionID, String Version) { RAMLibrary
* rlib = session .getLibrary(new
* com.ibm.ram.common.data.AssetIdentification( sessionID, Version));
* this.ramLibary = rlib; }
*/
public void setRamAsset(String sessionID, String Version) {
RAMAsset asset = session
.getAsset(new com.ibm.ram.common.data.AssetIdentification(
sessionID, Version));
this.ramAsset = asset;
}
@Override
public void generateAssetReport(String assetID) {
if (assetID != null) {
AssetAttribute collectionOfAttributes[] = getRamAsset()
.getAssetAttributes();
for (AssetAttribute ac : collectionOfAttributes) {
System.out.println(ramAsset.getAssetAttribute(ac.getName()));
}
}
}
}
@Override
public void generateAssetReport(String assetID) {
if (assetID != null) {
AssetAttribute collectionOfAttributes[] = getRamAsset()
.getAssetAttributes();
for (AssetAttribute ac : collectionOfAttributes) {
System.out.println(ramAsset.getAssetAttribute(ac.getName()));
}
}
}
this gives me all of the assets attributes but no asset version number or description (argggggg). In order to get asset version numbers/description you have to use a different pkg, which is found in the RAMLibrary.
The code to extract RAMLibrary is failing miserably, this is where I need help. Can anyone tell what I'm doing wrong, why am I getting a null pointer for AssetIdentification ai? Please note that this technique has been used successfully when getting RAMAssets attributes, but its not working when I'm trying to capture RAMLibrary information.
Active Code:
public class RAMLibMain {
public void test() {
String assetGUID = "6D0429E3-5134-9B03-4278-14306CDB2230";
String assetVersion = "3.0";
AssetIdentification ai = new AssetIdentification(assetGUID,
assetVersion);
RAMSession rtsession = new RAMSession("http://localhost:9080/ram", "admin", "admin");
try {
String st = rtsession.getLibrary(ai).getVersion();
System.out.println("test: " + st);
}catch (Exception ex) {
ex.getMessage();
ex.printStackTrace();
}
}
public static void main(String[] args) {
System.out
.println("RamLibrary Client Started capturing RAM library Data");
RAMLibMain rlm = new RAMLibMain();
rlm.test();
}
}
Accepted answer
I'm not exactly sure what you are trying to do. AssetAttributes having nothing to do with libraries per se. Nor do I understand what version has to do with AssetAttributes.
But about NPE on ai? You wouldn't be getting an NPE on ai itself, but getLibrary(ai) will return null if the asset being requested IS NOT a library or if the asset doesn't exist. So you would be getting the NPE on the null.getVersion() instead in that case.
But about NPE on ai? You wouldn't be getting an NPE on ai itself, but getLibrary(ai) will return null if the asset being requested IS NOT a library or if the asset doesn't exist. So you would be getting the NPE on the null.getVersion() instead in that case.
Comments
Gerald Gordon
Dec 11 '12, 9:08 a.m.