Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Not able to delete a subscription using the RAM 7511 java api

I used the below code snippet to delete a subscription that gets added to an asset when it is created.

    public static void main(String[] args) throws RAMAccessException {
        RAMClient obj=RAMClient.getInstance();
        RAMAsset asset=obj.getAsset("AC59BBF7-E4E9-7A43-F8D1-D054933519F4", "1.0");
        RAMSubscription[] subscriptions=asset.getSubscriptions();
       
        for(RAMSubscription subscription:subscriptions){
            subscription.setAction(RAMAction.DELETE);
            asset.addSubscription(subscription);
            obj.session.put(asset, new RAMStatusMonitor());
            System.out.println("Deleted the subscription");
        }
       
    But i noticed that i am able to fetch the subscription details even after executing the above code and in addition the subscription can also be seen on the UI.

Can you please help me with this issue?

    }

0 votes

Comments

BTW: If you do not WANT to have subscriptions automatically added to assets you create then you can set this preference for yourself.

Go to My Dashboard->Edit and one of the checkbox on the page will say "Automatically subscribe to assets you create" Have this checkbox not checked and you will no longer get these subscriptions created for assets you create.



One answer

Permanent link
In the for loop, remove the asset.addSubscription(subscription); statement. Setting the action to RAMAction.DELETE is the only thing required. Also it's not necessary to update the asset inside the loop. If you have multiple subscriptions, it gets expensive to update the asset everytime.

Just a suggestion but in the println you could include the user as well.

Here's the code I executed against our 7.5.1.1 development test server:

    public static RAMSession session = null;

    public static void main(String[] args) {
        session = new RAMSession("http://<ram_server_url>/", "admin_userid", "admin_password");
        RAMAsset asset = session.getAsset(new AssetIdentification("asset_guid", "asset_version"));
        RAMSubscription[] subscriptions = asset.getSubscriptions();

        for (RAMSubscription subscription : subscriptions) {
            subscription.setAction(RAMAction.DELETE);
            System.out.println("Deleted the subscription for user" + subscription.getUser());
        }
        session.put(asset, new RAMStatusMonitor());
    }

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Dec 06 '12, 1:31 a.m.

Question was seen: 4,643 times

Last updated: Dec 11 '12, 10:29 a.m.

Confirmation Cancel Confirm