use of org.thingsboard.server.common.data.id.PluginId in project thingsboard by thingsboard.
the class BasicRpcSessionListener method deserialize.
private static ToPluginRpcResponseDeviceMsg deserialize(ServerAddress serverAddress, ClusterAPIProtos.ToPluginRpcResponseRpcMessage msg) {
ClusterAPIProtos.PluginAddress address = msg.getAddress();
TenantId pluginTenantId = new TenantId(toUUID(address.getTenantId()));
PluginId pluginId = new PluginId(toUUID(address.getPluginId()));
RpcError error = !StringUtils.isEmpty(msg.getError()) ? RpcError.valueOf(msg.getError()) : null;
FromDeviceRpcResponse response = new FromDeviceRpcResponse(toUUID(msg.getMsgId()), msg.getResponse(), error);
return new ToPluginRpcResponseDeviceMsg(pluginId, pluginTenantId, response);
}
use of org.thingsboard.server.common.data.id.PluginId in project thingsboard by thingsboard.
the class BasePluginService method suspendPluginById.
@Override
public void suspendPluginById(PluginId pluginId) {
PluginMetaData plugin = pluginDao.findById(pluginId);
List<RuleMetaData> affectedRules = ruleDao.findRulesByPlugin(plugin.getApiToken()).stream().filter(rule -> rule.getState() == ComponentLifecycleState.ACTIVE).collect(Collectors.toList());
if (affectedRules.isEmpty()) {
updateLifeCycleState(pluginId, ComponentLifecycleState.SUSPENDED);
} else {
throw new DataValidationException("Can't suspend plugin that has active rules!");
}
}
use of org.thingsboard.server.common.data.id.PluginId in project thingsboard by thingsboard.
the class PluginMetaDataEntity method toData.
@Override
public PluginMetaData toData() {
PluginMetaData data = new PluginMetaData(new PluginId(getId()));
data.setTenantId(new TenantId(fromString(tenantId)));
data.setCreatedTime(UUIDs.unixTimestamp(getId()));
data.setName(name);
data.setClazz(clazz);
data.setPublicAccess(publicAccess);
data.setState(state);
data.setApiToken(apiToken);
data.setConfiguration(configuration);
data.setAdditionalInfo(additionalInfo);
return data;
}
use of org.thingsboard.server.common.data.id.PluginId in project thingsboard by thingsboard.
the class JpaBasePluginDaoTest method createPlugin.
private void createPlugin(UUID tenantId, String namePrefix, int i) {
PluginMetaData plugin = new PluginMetaData();
plugin.setId(new PluginId(UUIDs.timeBased()));
plugin.setTenantId(new TenantId(tenantId));
plugin.setName(namePrefix + i);
pluginDao.save(plugin);
}
use of org.thingsboard.server.common.data.id.PluginId in project thingsboard by thingsboard.
the class PluginController method activatePluginById.
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@RequestMapping(value = "/plugin/{pluginId}/activate", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void activatePluginById(@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.activatePluginById(pluginId);
actorService.onPluginStateChange(plugin.getTenantId(), plugin.getId(), ComponentLifecycleEvent.ACTIVATED);
logEntityAction(plugin.getId(), plugin, null, ActionType.ACTIVATED, null, strPluginId);
} catch (Exception e) {
logEntityAction(emptyId(EntityType.PLUGIN), null, null, ActionType.ACTIVATED, e, strPluginId);
throw handleException(e);
}
}
Aggregations