It's all about the answers!

Ask a question

RAM Custom Policy


Bilal Ahmed (5611) | asked Dec 06 '11, 10:37 p.m.
Hi,

I am developing custom policies in RAM.

(a) Is there any way to send email notifications to users, given that I have the user-ids and the email addresses. I am currently not using the Collaborative Voting mechanism and at this stage intend not to.

(b) Is there a way to make use of the default "Send Email" policy in custom policies, i.e. can I access the java classes that are used in the "Send Email" default policy.

(c) Is there a way to create "hidden" or "invisible" attributes attached to an asset, which cannot be changed or updated by the user but can be used as a flag in the policy.

Thanks

8 answers



permanent link
Saurabh Agarwal (111123) | answered Dec 07 '11, 2:09 p.m.
JAZZ DEVELOPER
Hi,
a) You can send email to others by using Send Email policy. There is a field that takes in the input of others email addresses, and you can add your own message.


b) In RAM 751 we do have the ability to define he attributes that are hidden.

permanent link
Bilal Ahmed (5611) | answered Dec 07 '11, 7:55 p.m.
Hi,
a) You can send email to others by using Send Email policy. There is a field that takes in the input of others email addresses, and you can add your own message.


b) In RAM 751 we do have the ability to define he attributes that are hidden.


Thanks Saurabh,

(a) Yes I am aware of the "Send Email" policy in RAM, but I wanted to know if there was a way to use those java classes in the the custom policy code that I am developing.

(b) Are there any instructions on how to create the hidden attributes?

Appreciate your help.

permanent link
Saurabh Agarwal (111123) | answered Dec 08 '11, 8:54 a.m.
JAZZ DEVELOPER
a. The java classes are interna APIs and we cannot guarantee that it will not change in future. So I would not go that path.
You can override the methods of the SendEmail policy but thats also not public API.
The other option is to write your own java code to send email.

b. To create hidden attributes, its only available in RAM 751. When you go to asset types to add attribute constraint, you will see that the attributes can now be grouped and one group is hidden attributes. You can drag and drop any attribute in that group and that will mark it hidden

permanent link
Bilal Ahmed (5611) | answered Dec 08 '11, 11:52 p.m.
a. The java classes are interna APIs and we cannot guarantee that it will not change in future. So I would not go that path.
You can override the methods of the SendEmail policy but thats also not public API.
The other option is to write your own java code to send email.

b. To create hidden attributes, its only available in RAM 751. When you go to asset types to add attribute constraint, you will see that the attributes can now be grouped and one group is hidden attributes. You can drag and drop any attribute in that group and that will mark it hidden


Thanks Saurabh, appreciate your help.

permanent link
Bilal Ahmed (5611) | answered Dec 08 '11, 11:57 p.m.
I am trying to subscribe users to an asset in an active RAM session:

RAMSubscription newSub = new RAMSubscription("NEW_POLICY", addUser);

newSub.setFrequency(Frequency.WEEKLY);
ramAsset.addSubscription(newSub);
session.put(ramAsset, new RAMStatusMonitor());



And I keep getting null pointer exception:


This policy encountered an error during execution.
java.lang.NullPointerException at com.ibm.ram.client.RAMAsset.addSubscription(RAMAsset.java:1260) at com.ibm.ram.extension.TestNotifications.test(TestNotifications.java:122) at com.ibm.ram.repository.lifecycle.AssetLifecycleManager.runAssetPolicies(AssetLifecycleManager.java:2418) at


TestNotifications.java:122 is ramAsset.addSubscription(newSub);

permanent link
Saurabh Agarwal (111123) | answered Dec 09 '11, 9:12 a.m.
JAZZ DEVELOPER
Which version of RAM are you using?
how are you creating the session ?

I am trying to subscribe users to an asset in an active RAM session:

RAMSubscription newSub = new RAMSubscription("NEW_POLICY", addUser);

newSub.setFrequency(Frequency.WEEKLY);
ramAsset.addSubscription(newSub);
session.put(ramAsset, new RAMStatusMonitor());



And I keep getting null pointer exception:


This policy encountered an error during execution.
java.lang.NullPointerException at com.ibm.ram.client.RAMAsset.addSubscription(RAMAsset.java:1260) at com.ibm.ram.extension.TestNotifications.test(TestNotifications.java:122) at com.ibm.ram.repository.lifecycle.AssetLifecycleManager.runAssetPolicies(AssetLifecycleManager.java:2418) at


TestNotifications.java:122 is ramAsset.addSubscription(newSub);

permanent link
Saurabh Agarwal (111123) | answered Dec 09 '11, 10:33 a.m.
JAZZ DEVELOPER
Opened a defect
https://jazz.net/jazz02/resource/itemName/com.ibm.team.workitem.WorkItem/59541




Which version of RAM are you using?
how are you creating the session ?

I am trying to subscribe users to an asset in an active RAM session:

RAMSubscription newSub = new RAMSubscription("NEW_POLICY", addUser);

newSub.setFrequency(Frequency.WEEKLY);
ramAsset.addSubscription(newSub);
session.put(ramAsset, new RAMStatusMonitor());



And I keep getting null pointer exception:


This policy encountered an error during execution.
java.lang.NullPointerException at com.ibm.ram.client.RAMAsset.addSubscription(RAMAsset.java:1260) at com.ibm.ram.extension.TestNotifications.test(TestNotifications.java:122) at com.ibm.ram.repository.lifecycle.AssetLifecycleManager.runAssetPolicies(AssetLifecycleManager.java:2418) at


TestNotifications.java:122 is ramAsset.addSubscription(newSub);

permanent link
Bilal Ahmed (5611) | answered Dec 09 '11, 11:10 p.m.
(a) RAM Version: V7.5.0.2
Build: RAM7502-I20110308_1504


(b) Session:

RAMSession session = new RAMSession("http://servert:8080/ram", "user", "pass");

I can successfully update the RAM asset in the active session , i.e. change its name, which suggests there is nothing wrong with the session.

Following are the steps that I am using:

1. Create RAMSession.
2. Retrieve RAMAsset
3. Create a new RAMSubscription using:

RAMSubscription newSub = new RAMSubscription("NEW_POLICY", addUser);

newSub.setFrequency(Frequency.WEEKLY);
ramAsset.addSubscription(newSub);
session.put(ramAsset, new RAMStatusMonitor());


ramAsset.addSubscription(newSub);
This is where the policy fails. I then commented out this line to investigate the Subscription I created:


RAMSubscription.getFrequency() = WEEKLY - CORRECTLY SET

[b]RAMSubscription. getIdentifier() = null [/b]-? Not sure why

RAMSubscription.getName() = NEW_POLICY - CORRECTLY SET

[b]RAMSubscription.getResourceURI() = null[/b] ? Not sure why

RAMSubscription.getUser() = addUser - CORRECTLY SET


RAMSubscription. getIdentifier() = null and
RAMSubscription.getResourceURI() = null Not sure why this is happening.

One other thing might be that as per the documentation in the Info Center there are only eight session level objects:

RAMAsset
RAMCommunity
RAMAssetType
RAMCategorySchema
RAMRelationshipType
RAMAssetAttribute
RAMUser
RAMLibrary

But as per the Subscription example on the Info Center this should not be a problem.

Example: http://publib.boulder.ibm.com/infocenter/ramhelp/v7r5m0/index.jsp?topic=%2Fcom.ibm.ram.web.nav.doc%2Ftopics%2Fhelpindex_ram.html


The other thing is that Retrieve Asset Subscriptions terminates the policy execution i.e. the policy fails without any error messages ie stack trace at the following line:

//Retrieve Asset Subscriptions
RAMSubscription[] subs = asset.getSubscriptions();


From RAMAsset.class
addSubscription Method

// Method descriptor #1070 (Lcom/ibm/ram/client/RAMSubscription;)V
// Stack: 2, Locals: 2
public void addSubscription(com.ibm.ram.client.RAMSubscription subscription);
0 aload_1
1 aload_0
2 invokevirtual com.ibm.ram.client.RAMSubscription.setAsset(com.ibm.ram.client.RAMAsset) : void
5 aload_1
6 aconst_null
7 invokevirtual com.ibm.ram.client.RAMSubscription.setIdentifier(java.lang.String) : void
10 aload_1
11 invokevirtual com.ibm.ram.client.RAMSubscription.getUser() : com.ibm.ram.client.RAMUser
14 ifnonnull 28
17 aload_1
18 aload_0
19 invokevirtual com.ibm.ram.client.RAMAsset.getSession() : com.ibm.ram.client.RAMSession
22 invokevirtual com.ibm.ram.client.RAMSession.getUser() : com.ibm.ram.client.RAMUser
25 invokevirtual com.ibm.ram.client.RAMSubscription.setUser(com.ibm.ram.client.RAMUser) : void
28 aload_1
29 getstatic com.ibm.ram.client.RAMAction.CREATE : com.ibm.ram.client.RAMAction
32 invokevirtual com.ibm.ram.client.RAMSubscription.setAction(com.ibm.ram.client.RAMAction) : void
35 aload_0
36 getfield com.ibm.ram.client.RAMAsset.fSubscriptions : java.util.List
39 aload_1
40 invokeinterface java.util.List.add(java.lang.Object) : boolean
45 pop
46 aload_0
47 iconst_1
48 invokevirtual com.ibm.ram.client.RAMAsset.setSubscriptionsDirty(boolean) : void
51 return
Line numbers:





<---- This is what shows up in the Null Pointer Exception. Not sure what it refers to in the actual RAMAsset Class.


Local variable table:
local: this index: 0 type: com.ibm.ram.client.RAMAsset
local: subscription index: 1 type: com.ibm.ram.client.RAMSubscription

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.