It's all about the answers!

Ask a question

Working with 7.5.1.1 RAM java api. RAMLibrary is returning null.


Gerald Gordon (7011319) | asked Dec 10 '12, 4:44 p.m.
 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();

}
}



Comments
Gerald Gordon commented Dec 11 '12, 9:08 a.m.

String st = rtsession.getLibrary(ai).getDescription();

I guess getting version does not make much sense since I'm passing it in... but getDescription from the RAMLIbrary is more pratical.

Accepted answer


permanent link
Rich Kulp (3.6k38) | answered Dec 11 '12, 10:46 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
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.
Gerald Gordon selected this answer as the correct answer

Comments
Gerald Gordon commented Dec 11 '12, 11:05 a.m. | edited Dec 11 '12, 11:06 a.m.

Looking for the following information when I submit a RAMAsset: Name, Version, Community, Type, Short Description.  These are mandatory attributes when submitting an asset that were dictated by the RAM application (7.5.1.1).

When I use the RAM java api to pull in the AssetAttriubtues I get the following information but not the mandatory information, how do I get the aforementioned information using the RAM java api.:

RamJava Client Started capaturing RAM attribute Data

Environment Deployment Topology =

Deloyment Description = Nov. Major Release of Premier Connect

FEATURE BUNDLE = 1

List of Stories/Tasks = RA12345, RA23456, RA4567

Deploy DAsset to NON PROD ENV = PERFORMANCE

Database Updates Required = true

Describe Deployment Order = Perform database updates first

SCHEDULE DEPLOYMENT DATE = 2012-11-10

SCHEDULE DEPLOYMENT TIME = 12:01am

etc......


Gili Mendel commented Dec 12 '12, 8:26 a.m.
JAZZ DEVELOPER

k, lets clarify your question a bit,

You are getting a RAMAsset, from a RAMSession, and user the getAssetAttributes() to list all the custom attributes that are SET on that asset (e.g., if you created an asset without that custom attribute, you will not get it here).

Note that short/description, version, community ... are not custom attributes.  These properties have explicit API directly on the RAMAsset  (e.g., getShortDescription()).

What is it that you are missing from that RAMAsset?


Gerald Gordon commented Dec 12 '12, 9:49 a.m. | edited Dec 12 '12, 9:51 a.m.


Great! Clarification.

Yes I would like to access the properties of the RAMAsset via the RAM JAVA API.

How do I get these properties "short/description, version, community" via the java api?

I think you are saying that I can access these properties by using the RAMAsset class directly? is this correct.  RAMAsset ramasset = new RAMAsset();

ramasset.getShortDescription(); for example.

Kind regards,


Gerald Gordon commented Dec 12 '12, 10:14 a.m.

I tested this out, its actually RAMAsset ramAsset= rtsession.getAsset(new com.ibm.ram.common.data.AssetIdentification(sessionID, Version));

And now I can get the RAM Asset properties that I seek: ramAsset.getShortDescription(); getCommunityName(); etc...

Thanks Gili, I'm all set.

Your answer


Register or to post your answer.