use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class PluginController method getPlugins.
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@RequestMapping(value = "/plugins", method = RequestMethod.GET)
@ResponseBody
public List<PluginMetaData> getPlugins() throws ThingsboardException {
try {
if (getCurrentUser().getAuthority() == Authority.SYS_ADMIN) {
return checkNotNull(pluginService.findSystemPlugins());
} else {
TenantId tenantId = getCurrentUser().getTenantId();
List<PluginMetaData> plugins = checkNotNull(pluginService.findAllTenantPluginsByTenantId(tenantId));
plugins.stream().filter(plugin -> plugin.getTenantId().getId().equals(ModelConstants.NULL_UUID)).forEach(plugin -> plugin.setConfiguration(null));
return plugins;
}
} catch (Exception e) {
throw handleException(e);
}
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class PluginController method suspendPluginById.
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@RequestMapping(value = "/plugin/{pluginId}/suspend", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void suspendPluginById(@PathVariable(PLUGIN_ID) String strPluginId) throws ThingsboardException {
checkParameter(PLUGIN_ID, strPluginId);
try {
PluginId pluginId = new PluginId(toUUID(strPluginId));
PluginMetaData plugin = checkPlugin(pluginService.findPluginById(pluginId));
pluginService.suspendPluginById(pluginId);
actorService.onPluginStateChange(plugin.getTenantId(), plugin.getId(), ComponentLifecycleEvent.SUSPENDED);
logEntityAction(plugin.getId(), plugin, null, ActionType.SUSPENDED, null, strPluginId);
} catch (Exception e) {
logEntityAction(emptyId(EntityType.PLUGIN), null, null, ActionType.SUSPENDED, e, strPluginId);
throw handleException(e);
}
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class JpaBasePluginDao method findById.
@Override
public PluginMetaData findById(PluginId pluginId) {
log.debug("Search plugin meta-data entity by id [{}]", pluginId);
PluginMetaData pluginMetaData = super.findById(pluginId.getId());
if (log.isTraceEnabled()) {
log.trace("Search result: [{}] for plugin entity [{}]", pluginMetaData != null, pluginMetaData);
} else {
log.debug(SEARCH_RESULT, pluginMetaData != null);
}
return pluginMetaData;
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class RuleActorMessageProcessor method fetchPluginInfo.
private void fetchPluginInfo() {
if (!StringUtils.isEmpty(ruleMd.getPluginToken())) {
PluginMetaData pluginMd = systemContext.getPluginService().findPluginByApiToken(ruleMd.getPluginToken());
pluginTenantId = pluginMd.getTenantId();
pluginId = pluginMd.getId();
}
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BasePluginService method checkRulesAndDelete.
private void checkRulesAndDelete(UUID pluginId) {
PluginMetaData plugin = pluginDao.findById(pluginId);
List<RuleMetaData> affectedRules = ruleDao.findRulesByPlugin(plugin.getApiToken());
if (affectedRules.isEmpty()) {
pluginDao.deleteById(pluginId);
} else {
throw new DataValidationException("Plugin deletion will affect existing rules!");
}
}
Aggregations