RAM API: Is there a way to create a Search Subscription for a particular User?
Is there any way from the RAM API that you can create a subscription like this for a user?
We are using RAM 7.5.2.1. Thanks.
- Troy Klomp
2 answers
SearchQuery query = session.createAssetQuery("asset"); RAMAssetQueryBuilder queryBuilder = (RAMAssetQueryBuilder)query; SearchResult result = session.getAssets(queryBuilder); for(AssetSearchResult assetRe:result.getAssetSearchResults()){ RAMAsset asset = session.getAsset(assetRe.getAsset().getIdentification()); asset.addSubscription(new RAMSubscription("my sub", session.getUser("admin"))); try{ session.queueAssetForPut(asset); }catch(Exception e){ e.printStackTrace(); //if asset locked. ignore } }
PS: use RAMSubscription.setFrequency to make a weekly subscription.
Comments
Thanks for the reply, but this is not what we are looking for. The above sample code does a search for assets, and creates a subscription to every asset currently found in the search. So, the search is run once, and all individual assets (that already exist) are subscribed. The user would then have multiple subscriptions to manage for all of the assets found.
We are looking for a subscription to the search criteria, so that if any assets are created or updated that match that search criteria, users would be notified. So, the search would be run on a scheduled basis (e.g., daily, weekly), and the subscription would be on the search results, if any assets are created or updated. The user would have just one subscription to manage (where are these stored?), so it would be easy to unsubscribe if desired.
1 vote