It's all about the answers!

Ask a question

How to create a subCategory in RAM using Java API


Sourav Ghosh (1266) | asked Feb 07 '13, 11:12 a.m.
I have a method which is intended to create a subcategory .. but it fails with the following error:-


com.ibm.ram.common.data.exception.RAMRuntimeException
    at com.ibm.ram.client.RAMSession.putCategorySchema(RAMSession.java:3776)
    at com.ibm.ram.client.RAMSession.put(RAMSession.java:5041)
    at com.cof.custom.policy.CustomPolicyUtility.categorizeSubCategoryAssets(CustomPolicyUtility.java:488)
    at com.cof.custom.policy.CustomPolicyUtility.manageAssets(CustomPolicyUtility.java:425)
    at com.cof.custom.policy.CustomPolicyUtility.main(CustomPolicyUtility.java:755)
Caused by: java.lang.NullPointerException
    at com.ibm.ram.client.RAMSession.putCategorySchema(RAMSession.java:3666)
    ... 4 more
Exception in thread "main" com.ibm.ram.common.data.exception.RAMRuntimeException
    at com.ibm.ram.client.RAMSession.putCategorySchema(RAMSession.java:3776)
    at com.ibm.ram.client.RAMSession.put(RAMSession.java:5041)


My code goes like this :-

        CategorySchema categorySchema = session.getCategorySchema(CustomPolicyConstants.BUSINESS_CAPABILITY_CATALOG);
RAMCategory  bcCategory = (RAMCategory)categorySchema.getCategory(CustomPolicyConstants.BUSINESS_CAPABILITIES_ASSET_TYPE);

SubCategory subCategory = bcCategory.createSubCategory("NewSubCategory4");
getRAMSession().put(categorySchema, new RAMStatusMonitor());

Can anyone please shed light on this and let me know what am I doing wrong?

Thanks in advance for all your help.

Comments
Rich Kulp commented Feb 07 '13, 1:12 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

What is the exact version of the RAM client that you are using? I can't find out which  version that the line numbers shown match up with.

11 answers



permanent link
Sourav Ghosh (1266) | answered Feb 07 '13, 3:04 p.m.
I am working with RAM v7.5.1 and developing Java code to customize the RAM server. My objective is that when user creates/approves an asset of type "SubCategory" that subcategory should be visible in the left-hand catalog schema hierarchy. Please let me know if there are other approaches of resolution to the problem.

Comments
Gili Mendel commented Feb 08 '13, 8:15 a.m.
JAZZ DEVELOPER

Sure it is 7.5.1? any test fixes? check the help->About ... what build is it?

... also, make sure to use the client library from that server.


permanent link
Sourav Ghosh (1266) | answered Feb 08 '13, 9:27 a.m.
Yes, it is version 7.5.1 build RAM7511-I20120320_1046. It has the following test fixes.


Erroneous directory on RAM server - port to 7511
Port to 7511 tf7 - Put version info, database info into support logs zip
Unable to change states on rich client in test fix 6
"yum install ruby" does not install the dependent ruby-libs package
RATLC02508375 Asset details page keeps refreshing when asset has relationships - port to 7511
RATLC02507178 - IE8 - saving large lifecycles on asset details page takes a long time
RATLC00331011 - Performance issue with large category schema - port to 7511

RATLC02507583 - Search for users using unique ids in the License Management page - port to 7511
Retired lifecycle assets migrated to 7.5.1.1 can be accessed by all and lost role override settings regular lifecycles.
RATLC02507178 - 7.5.1.1 Fix - Workflows are serialized multiple times in JSON lifecycle
Legacy owners lost capability to change owners and permissions on an asset
RATLC02507387 Cannot search by date in IE8 - ported from 7512 for 7511 testfix5
RATLC02507531 - RAM 7.5.0.2 to 7.5.1.1 migration creates duped polices, expired draft assets visible, and lost role override setting
RATLC00330986 (ER) Assets using legacy reviews are viewable in draft state by all signed-in users.
RATLC00330967 - Client query using query shortcut returns no results - port to 7511
RATLC02507587 - Categories missing from Asset Search Filter - port to 7511
RTC 4 can not specify RAM as a friend server - port to 7511

RATLC02507178 - governor for each policy in the lifecycle serialized - port to 7511
Enable condition-sensitive YUM repositories (based on a tag, category, relative time, or combination)
Artifact indexer may skip assets if the indexing process is shutdown in the middle of indexing - port to 7511
RATLC02507055 - Artifact label is moving when adding to contents - port to 7511
RATLC00330846(CR) - LDAP User groups not populating correctly
RATLC00330954 - RAM 7511 backport for [wi 65504] "Assets Using This Forum" pager broken
Unable to get artifacts after RAMSession.release() - port to 7511
RATLC02506457 - Asset index job should not fail if DB metrics query iterator that retrieves deleted metrics fails - port to 7511
Available relationships on submit page are not correct when relationship constraints are defined on the asset type - port to 7511
When downloading a 5GB+ artifact / file through ncram webserver file stops at 2GB - port to 7511
UserUpdate Job fails with null value set into a not null column - port to 7511

RATLC02505865 - Modify Asset Owner policy does not find attribute selected in the policy configuration - port back to 7511
The domain element of assetServices should be resource - port to 7511
OSLC v2 asset search does not return any assets - port back to 7511
RATLC01347734 - Search for assets by tag does not yield results in 7.5.1.1 RAM
RPM policy fails on certain rpms - port to 7511
OSLC Asset 2.0 implementation does not deserialize asset type - port to 7511
RATLC02506339 - Users may not be able to create or modify assets after previously abandoning a modification or submission - port to 7511
Ant : Support to add self defined attributes
DevOps : Need ability to clear session cache in Ant
DevOps : Ability to create ram asset with a guid and version on the server using ant script
Unable to retire asset in a lifecycle - port back to 7511
AssetExpiration job is throwing an NPE in RAMSchemaAccess71.modifyAssetState and AssetUndoActivity.undo throwing NPE
AssetBusy on AssetExpirationJob causes entire job to end.
MailMan doesn't stop running when it get's an SMTP server down - port to 7.5.1.1 fix2
SecurityManager.clearCache had a race condition on Process Admin
ArtifactCacheRefreshJob trying to update locked assets
Indexers NPE on metrics query of role
JobQueueManager goes into a "loop" trying to create a singleton job if one already there but not yet available


Comments
Rich Kulp commented Feb 08 '13, 10:24 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

Just an FYI:

7.5.1 and 7.5.1.1 are not the same in RAM. Also just the testfix number would be sufficient. We don't need the list of actual defects. So you can say simply RAM 7.5.1.1 testfix 7d.

We need to know this information on any RAM question. This is because there are many different levels of RAM out there and they all have many differences from the previous ones.

I'll go see if I can see any problems with testfix 7 that would cause this.

Thanks.


Rich Kulp commented Feb 08 '13, 10:36 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

OK, we have another problem. The version of RAM you gave us was naturally the server version. The problem is that your error is occurring in the ramclient and not the server. Your ramclient does not appear to be from 7511. The line numbers don't quite match up.

So can you please do the following, look in the directory where you are storing your ramclient.zip jars and tell me:

a) The entire name of the jar that starts with the name com.ibm.ram.common?
b) Are there any files in this directory labeled something like testfix12RamClient.xml? What are they named?
c) Open the ramclient.jar and go to the META-INF\MANIFEST.MF file and tell me what the Created-By: entry in the manifest says?

These three together will tell me the version of the ramclient being used.

Thanks


permanent link
Sourav Ghosh (1266) | answered Feb 08 '13, 1:51 p.m.
a) The entire name of the jar that starts with the name com.ibm.ram.common?
Ans. The full name of the jar is com.ibm.ram.common_7.5.11.v20121127_0009
b) Are there any files in this directory labeled something like testfix12RamClient.xml? What are they named?
Ans. No.
c) Open the ramclient.jar and go to the META-INF\MANIFEST.MF file and tell me what the Created-By: entry in the manifest says?
Ans. IBM Rational CCB, build RAM7512-I20121126_1908


Comments
Rich Kulp commented Feb 11 '13, 11:51 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

Ah, you are using an internal build that has never been published. I'm not sure why it is failing.


Rich Kulp commented Feb 11 '13, 12:05 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

Did you do a session.release() somewhere between the

session.getCategorySchema(CustomPolicyConstants.BUSINESS_CAPABILITY_CATALOG);

and the

getRAMSession().put(categorySchema, new RAMStatusMonitor());

That is the only way I could see an NPE at the given location.


permanent link
Sourav Ghosh (1266) | answered Feb 11 '13, 2:07 p.m.
But the sub-category ultimately shows up in the catalog schema hierarchy when I create an asset under that newly created sub-category.  But is should show up after I create the sub-category.

permanent link
Sourav Ghosh (1266) | answered Feb 11 '13, 2:56 p.m.
Should I be using a different build which was already published?
May I know the benefits of using a published build?

I have not done any session.release() anywhere in the code.


permanent link
Sourav Ghosh (1266) | answered Feb 11 '13, 2:58 p.m.
This is the code that I am using

/**
 *
 */
package com.cof.custom.policy;

import com.ibm.ram.client.RAMAsset;
import com.ibm.ram.client.RAMAssetQueryBuilder;
import com.ibm.ram.client.RAMCategory;
import com.ibm.ram.client.RAMCategorySchema;
import com.ibm.ram.client.RAMSession;
import com.ibm.ram.client.RAMSubCategory;
import com.ibm.ram.client.status.RAMStatusMonitor;
import com.ibm.ram.common.data.AssetSearchResult;
import com.ibm.ram.common.data.Relationship;
import com.ibm.ram.common.data.SearchResult;

/**
 * @author fvz857
 *
 */
public class TestCreateSubCategory {
   
    public static RAMSession getRAMSession() {
        RAMSession session = new RAMSession("https://10.42.102.20:11602/ram.ws","fvz857", "fvz857");
        return session;
    }
    public static void categorizeSubCategoryAssets() {

        RAMCategorySchema categorySchema = getRAMSession().getCategorySchema(CustomPolicyConstants.BUSINESS_CAPABILITY_CATALOG);
          RAMCategory bcCategory = (RAMCategory)categorySchema.getCategory(CustomPolicyConstants.BUSINESS_CAPABILITIES_ASSET_TYPE);
        RAMSubCategory sub = (RAMSubCategory) bcCategory.getSubCategory("Manage Delinquencies");
        RAMSubCategory subCategory = sub.createSubCategory("New Delinquencies");
       
        getRAMSession().put(categorySchema, new RAMStatusMonitor());
    }
   
    public static void main(String z[]){
        categorizeSubCategoryAssets();
    }

}


Comments
Rich Kulp commented Feb 11 '13, 3:45 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

   public static RAMSession getRAMSession() {
        RAMSession session = new RAMSession("https://10.42.102.20:11602/ram.ws","fvz857", "fvz857");
        return session;
    }

Every time you call getRAMSession() you are getting a brand new one. So the
getRAMSession().getCategorySchema() is a different ram session than the one retrieved via getRAMSession().put(...). You can't get a schema from one session and try to put it into a different session.

Not only that but you are leaking RAMSession's. You are required to do a session.release() on every RAMSession created. If you don't then session will leak and not logout.

Thanks,
Rich


permanent link
Sourav Ghosh (1266) | answered Feb 11 '13, 4:41 p.m.
Thank you so much for your help. It works and I am not getting the NPE. But the newly-created sub-category does not show-up in the catalog hierarchy. What else do I need to do to achieve that?

Comments
Rich Kulp commented Feb 11 '13, 5:16 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

I don't know what that means.  What is the "catalog hierarchy" and how are you getting it?

Does the show up on the host if you looked there?


permanent link
Sourav Ghosh (1266) | answered Feb 12 '13, 3:57 a.m.
It is the view that is available on RAM Web Client when searching for an asset. The left-side of the screen provides a "Visual Browse" view which can be used to browse to a particular asset.
The search can be filtered by either Category or Type or State or  Community.
When the user clicks on "Category", the category hierarchy is displayed.
Category
    Software Development
       Kind
          Process[1]
          Schema[1]
          Service[1]
          Web Application[3]

I was referring the above structure as the "Category schema" hierarchy.

My requirement is that when the user creates a subcategory, that should show up on this hierarchy in the current location.i.e. under the correct category or subcategory.


Comments
Rich Kulp commented Feb 12 '13, 9:58 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

That is a cached view. It is refreshed approximately once every ten minutes.

You need to first verify that the update actually worked on the host. Go to the Admin pages and verify that the schema has been updated. That view always shows the live current view. If that worked, then it will eventually show up on the search page.


Sheehan Anderson commented Feb 12 '13, 4:08 p.m.
JAZZ DEVELOPER

My understanding is that the category is missing from the visual browse.  Does it show up on the search page when you drill down to it?


permanent link
Sourav Ghosh (1266) | answered Feb 12 '13, 2:09 p.m.
Thanks for your help. Yes, I have checked the schema pages and verified that the category schema is updated but still not able to see the subcategory in the left view.

To do that I am going to Administration -> Category Schema to check the "update" column in the resulting view. Do you think that there are any filters that is set which is preventing the subcategory from getting displayed ?

However, when I try to create a new Asset, it shows up in the "Available categories" tree under the "Categories" tab.
After an asset is created under the newly created subCategory, then it shows up on the left side Category Schema view. Can there be any settings which determines that if there are no assets created under a sub-category, then that subCategory will not be displayed?

Please help.



Comments
Rich Kulp commented Feb 12 '13, 5:05 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

For Visual Browse top category to show up there must be at least one asset that has some child node of the category assigned to it. Until then nothing shows. But once there is at least one then it will show them all. BUT you need to close the visual browser after making the change. The categories for the visualbrowse are only retrieved once, when the browser is started. You need to close and reopen it to see the new sub-category.


permanent link
Sourav Ghosh (1266) | answered Feb 14 '13, 2:22 p.m.
So, I am trying to categorize the subcategory asset object with the newly created sub-category to be compliant with the fact that "there must be at least one asset that has some child node of the category assigned to it."

But it fails with the following error :-

Exception in thread "main" com.ibm.ram.common.data.exception.RAMRuntimeException: Subcategory Business Capability Catalog/Business Capabilities/Move Money & Process Payments/My Buss Cap Asset5 was not found for the asset My Buss Cap Asset5[1.0].
    at com.ibm.ram.client.RAMAsset.categorize(RAMAsset.java:2300)
    at com.cof.custom.policy.CustomPolicyUtility.createUpdateSubCategory(CustomPolicyUtility.java:531)
    at com.cof.custom.policy.CustomPolicyUtility.categorizeSubCategoryAssets(CustomPolicyUtility.java:493)
    at com.cof.custom.policy.CustomPolicyUtility.manageAssets(CustomPolicyUtility.java:424)
    at com.cof.custom.policy.CustomPolicyUtility.main(CustomPolicyUtility.java:849)

My program is as follows:-

public static void createUpdateSubCategory(RAMCategory category, RAMSubCategory subCategory, RAMAsset assetObj){
        RAMSubCategory matchedCategory = null;
       
        if(!isAssetExistsInCategory(subCategory, assetObj)){
            matchedCategory= subCategory.createSubCategory(assetObj.getName());
            try{
                assetObj.categorize(category, subCategory.getName() + "/" + assetObj.getName());
            }catch(Exception e){
                assetObj.categorize(matchedCategory);
            }
            session.put(assetObj, new RAMStatusMonitor());
            session.put(categorySchema, new RAMStatusMonitor());
        }else{
            matchedCategory = (RAMSubCategory)subCategory.getSubCategory(assetObj.getName());
            assetObj.categorize(matchedCategory);
            session.put(assetObj, new RAMStatusMonitor());
        }
        session.release();
    }

Thanks in advance for your help.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.