create: function (options) { var ref = require('utils').time; //Check if the options object has a createdtime attribute and populate it if ((options.attributes) && (options.attributes.hasOwnProperty('overview_createdtime'))) { options.attributes.overview_createdtime = ref.getCurrentTime(); } this._super.create.call(this, options); var asset = this.get(options.id); //TODO avoid get: expensive operation var assetPath = asset.path; var user = ctx.username; var userRoles = ctx.userManager.getRoleListOfUser(user); //Check whether the user has admin role var endpoint = storeConstants.PRIVATE_ROLE_ENDPOINT + user; for (var role in userRoles) { if (userRoles.hasOwnProperty(role) && userRoles[role] == storeConstants.ADMIN_ROLE) { endpoint = storeConstants.ADMIN_ROLE_ENDPOINT; } } //Subscribe the asset author for LC update event and asset update event notifier.subscribeToEvent(options.attributes.overview_provider, assetPath, endpoint, storeConstants.LC_STATE_CHANGE); notifier.subscribeToEvent(options.attributes.overview_provider, assetPath, endpoint, storeConstants.ASSET_UPDATE); },
create: function(options) { var ref = require('utils').time; //Check if the options object has a createdtime attribute and populate it if ((options.attributes) && ctx.rxtManager.getRxtField(ctx.assetType, 'overview_createdtime')) { options.attributes.overview_createdtime = ref.getCurrentTime(); } this._super.create.call(this, options); var asset = this.get(options.id); //TODO avoid get: expensive operation var assetPath = asset.path; var user = ctx.username; var userRoles = ctx.userManager.getRoleListOfUser(user); try { social.warmUpRatingCache(ctx.assetType + ':' + options.id); } catch (e) { log.warn("Unable to publish the asset: " + ctx.assetType + ":" + options.id + " to social cache. This may affect on sort by popularity function."); } //Check whether the user has admin role var endpoint = storeConstants.PRIVATE_ROLE_ENDPOINT + user; for (var role in userRoles) { if (userRoles.hasOwnProperty(role) && userRoles[role] == storeConstants.ADMIN_ROLE) { endpoint = storeConstants.ADMIN_ROLE_ENDPOINT; } } //Subscribe the asset author for LC update event and asset update event notifier.subscribeToEvent(options.attributes.overview_provider, assetPath, endpoint, storeConstants.LC_STATE_CHANGE); notifier.subscribeToEvent(options.attributes.overview_provider, assetPath, endpoint, storeConstants.ASSET_UPDATE); },
invokeLcAction: function(asset, action, lcName) { var success; if (lcName) { success = this._super.invokeLcAction.call(this, asset, action, lcName); } else { success = this._super.invokeLcAction.call(this, asset, action); } //trigger notification on LC state change notifier.notifyEvent(storeConstants.LC_STATE_CHANGE_EVENT, asset.type, asset.name, COMMENT, asset.path, ctx.tenantId); return success; }
invokeLcAction: function (asset, action) { var success = this._super.invokeLcAction.call(this, asset, action); //trigger notification on LC state change notifier.notifyEvent(storeConstants.LC_STATE_CHANGE_EVENT, asset.type, asset.attributes.overview_name, COMMENT, asset.path, ctx.tenantId); return success; }
update: function (options) { this._super.update.call(this, options); var asset = this.get(options.id); //TODO avoid get: expensive operation //trigger notification on asset update notifier.notifyEvent(storeConstants.ASSET_UPDATE_EVENT, asset.type, asset.attributes.overview_name, null, asset.path, ctx.tenantId); },