proj_name
stringclasses
131 values
relative_path
stringlengths
30
228
class_name
stringlengths
1
68
func_name
stringlengths
1
48
masked_class
stringlengths
78
9.82k
func_body
stringlengths
46
9.61k
len_input
int64
29
2.01k
len_output
int64
14
1.94k
total
int64
55
2.05k
relevant_context
stringlengths
0
38.4k
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/gateway-component/src/main/java/org/jetlinks/community/gateway/external/DefaultMessagingManager.java
DefaultMessagingManager
subscribe
class DefaultMessagingManager implements MessagingManager, BeanPostProcessor { private final Map<String, SubscriptionProvider> subProvider = new ConcurrentHashMap<>(); private final static PathMatcher matcher = new AntPathMatcher(); @Override public Flux<Message> subscribe(SubscribeRequest request) {...
return Flux.defer(() -> { for (Map.Entry<String, SubscriptionProvider> entry : subProvider.entrySet()) { if (matcher.match(entry.getKey(), request.getTopic())) { return entry.getValue() .subscribe(request) .map(v -...
198
154
352
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/gateway-component/src/main/java/org/jetlinks/community/gateway/external/dashboard/DashBoardSubscriptionProvider.java
DashBoardSubscriptionProvider
subscribe
class DashBoardSubscriptionProvider implements SubscriptionProvider { private final DashboardManager dashboardManager; public DashBoardSubscriptionProvider(DashboardManager dashboardManager) { this.dashboardManager = dashboardManager; } @Override public String id() { return "dashb...
return Flux.defer(() -> { try { Map<String, String> variables = TopicUtils.getPathVariables( "/dashboard/{dashboard}/{object}/{measurement}/{dimension}", request.getTopic()); return dashboardManager.getDashboard(variables.get("dashboard")) ...
171
265
436
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/gateway-component/src/main/java/org/jetlinks/community/gateway/external/socket/WebSocketMessagingHandler.java
WebSocketMessagingHandler
handle
class WebSocketMessagingHandler implements WebSocketHandler { private final MessagingManager messagingManager; private final UserTokenManager userTokenManager; private final ReactiveAuthenticationManager authenticationManager; // /messaging/{token} @Override @Nonnull public Mono<Void> ha...
String[] path = session.getHandshakeInfo().getUri().getPath().split("[/]"); if (path.length == 0) { return session.send(Mono.just(session.textMessage(JSON.toJSONString( Message.error("auth", null, "错误的请求") )))).then(session.close(CloseStatus.BAD_DATA)); }...
102
1,190
1,292
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/gateway-component/src/main/java/org/jetlinks/community/gateway/external/socket/WebSocketMessagingHandlerConfiguration.java
WebSocketMessagingHandlerConfiguration
webSocketMessagingHandlerMapping
class WebSocketMessagingHandlerConfiguration { @Bean public HandlerMapping webSocketMessagingHandlerMapping(MessagingManager messagingManager, UserTokenManager userTokenManager, ReactiveAuthenticationManager authenticationMa...
WebSocketMessagingHandler messagingHandler=new WebSocketMessagingHandler( messagingManager, userTokenManager, authenticationManager ); final Map<String, WebSocketHandler> map = new HashMap<>(1); map.put("/messaging/**", messagingHandler); f...
113
130
243
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/gateway-component/src/main/java/org/jetlinks/community/gateway/monitor/GatewayMonitors.java
GatewayMonitors
doGetDeviceGatewayMonitor
class GatewayMonitors { private static final List<DeviceGatewayMonitorSupplier> deviceGatewayMonitorSuppliers = new CopyOnWriteArrayList<>(); static final NoneDeviceGatewayMonitor nonDevice = new NoneDeviceGatewayMonitor(); static { } public static void register(DeviceGatewayMonitorSupplier ...
List<DeviceGatewayMonitor> all = deviceGatewayMonitorSuppliers.stream() .map(supplier -> supplier.getDeviceGatewayMonitor(id, tags)) .filter(Objects::nonNull) .collect(Collectors.toList()); if (all.isEmpty()) { return nonDevice; } if (all...
204
145
349
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/gateway-component/src/main/java/org/jetlinks/community/gateway/monitor/LazyDeviceGatewayMonitor.java
LazyDeviceGatewayMonitor
getTarget
class LazyDeviceGatewayMonitor implements DeviceGatewayMonitor { private volatile DeviceGatewayMonitor target; private Supplier<DeviceGatewayMonitor> monitorSupplier; public LazyDeviceGatewayMonitor(Supplier<DeviceGatewayMonitor> monitorSupplier) { this.monitorSupplier = monitorSupplier; } ...
if (target == null) { target = monitorSupplier.get(); } return target;
259
30
289
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/gateway-component/src/main/java/org/jetlinks/community/gateway/monitor/measurements/DeviceGatewayMeasurement.java
HistoryDimension
getValue
class HistoryDimension implements MeasurementDimension { @Override public DimensionDefinition getDefinition() { return CommonDimensionDefinition.history; } @Override public DataType getValueType() { return new IntType(); } @Override ...
return QueryParamEntity.newQuery() .where("target", type) .is("name", parameter.getString("gatewayId").orElse(null)) .doPaging(0, parameter.getInt("limit").orElse(1)) .between("timestamp", parameter.getDate("from").orElseGe...
151
216
367
<methods>public void <init>(org.jetlinks.community.dashboard.MeasurementDefinition) ,public org.jetlinks.community.dashboard.supports.StaticMeasurement addDimension(org.jetlinks.community.dashboard.MeasurementDimension) ,public Mono<org.jetlinks.community.dashboard.MeasurementDimension> getDimension(java.lang.String) ,...
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/gateway-component/src/main/java/org/jetlinks/community/gateway/spring/ProxyMessageListener.java
ProxyMessageListener
onMessage
class ProxyMessageListener implements MessageListener { private final Class<?> paramType; private final Object target; private final ResolvableType resolvableType; private final Method method; private final BiFunction<Object, Object, Object> proxy; private volatile Decoder<?> decoder; @Su...
try { boolean paramVoid = paramType == Void.class; try { Object val = proxy.apply(target, paramVoid ? null : convert(message)); if (val instanceof Publisher) { return Mono.from((Publisher<?>) val).then(); } ...
813
152
965
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/gateway-component/src/main/java/org/jetlinks/community/gateway/spring/SpringMessageBroker.java
SpringMessageBroker
postProcessAfterInitialization
class SpringMessageBroker implements BeanPostProcessor { private final EventBus eventBus; private final Environment environment; @Override public Object postProcessAfterInitialization(@Nonnull Object bean, @Nonnull String beanName) throws BeansException {<FILL_FUNCTION_BODY>} protected String co...
Class<?> type = ClassUtils.getUserClass(bean); ReflectionUtils.doWithMethods(type, method -> { AnnotationAttributes subscribes = AnnotatedElementUtils.getMergedAnnotationAttributes(method, Subscribe.class); if (CollectionUtils.isEmpty(subscribes)) { return; ...
220
473
693
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/gateway-component/src/main/java/org/jetlinks/community/gateway/supports/DefaultDeviceGatewayManager.java
DefaultDeviceGatewayManager
doReload
class DefaultDeviceGatewayManager implements DeviceGatewayManager { private final DeviceGatewayPropertiesManager propertiesManager; private final Map<String, DeviceGatewayProvider> providers = new ConcurrentHashMap<>(); private final ReactiveCacheContainer<String, DeviceGateway> store = ReactiveCacheCont...
return propertiesManager .getProperties(gatewayId) .flatMap(prop -> { DeviceGatewayProvider provider = this.getProviderNow(prop.getProvider()); return store .compute(gatewayId, (id, gateway) -> { if (gateway !=...
991
217
1,208
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/gateway-component/src/main/java/org/jetlinks/community/gateway/supports/DeviceGatewayProviders.java
DeviceGatewayProviders
getProviderNow
class DeviceGatewayProviders { private static final Map<String, DeviceGatewayProvider> providers = new ConcurrentHashMap<>(); public static void register(DeviceGatewayProvider provider) { providers.put(provider.getId(), provider); } public static Optional<DeviceGatewayProvider> getProvider(Str...
DeviceGatewayProvider gatewayProvider = providers.get(provider); if (null == gatewayProvider) { throw new I18nSupportException("error.unsupported_device_gateway_provider", provider); } return gatewayProvider;
167
63
230
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/excel/AbstractImporter.java
AbstractImporter
doImport
class AbstractImporter<T> { protected final FileManager fileManager; protected final WebClient client; protected abstract Mono<Void> handleData(Flux<T> data); protected abstract T newInstance(); protected void customImport(ImportHelper<T> helper) { } /** * 写出导入结果文件 * * ...
ImportHelper<T> importHelper = new ImportHelper<>(this::newInstance, this::handleData); customImport(importHelper); //导入JSON if (FORMAT_JSON.equalsIgnoreCase(format)) { return importHelper .doImportJson( FileUtils.readDataBuffer(client, f...
770
174
944
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/excel/DefaultImportExportService.java
DefaultImportExportService
getInputStream
class DefaultImportExportService implements ImportExportService { private WebClient client; private final FileManager fileManager; public DefaultImportExportService(WebClient.Builder builder, FileManager fileManager) { client = builder.build(); this.f...
return Mono.defer(() -> { if (fileUrl.startsWith("http")) { return client .get() .uri(fileUrl) .accept(MediaType.APPLICATION_OCTET_STREAM) .exchangeToMono(clientResponse -> clientResponse.bodyToMono(Res...
407
144
551
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/excel/converter/ArrayConverter.java
ArrayConverter
convertForRead
class ArrayConverter implements ConverterExcelOption{ private boolean array; private Class<?> elementType; private ConverterExcelOption converter; @Override public Object convertForWrite(Object val, ExcelHeader header) { return String.join(",", ConverterUtils.convertToList(v...
List<Object> list = ConverterUtils .convertToList(cell, val -> { if (converter != null) { val = converter.convertForRead(val, header); } if (elementType.isInstance(val)) { return val; } ...
171
144
315
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/excel/converter/DateConverter.java
DateConverter
cell
class DateConverter implements ConverterExcelOption, CellOption { private final String format; private final Class<?> javaType; @Override public Object convertForWrite(Object val, ExcelHeader header) { return new DateTime(CastUtils.castDate(val)).toString(format); } @Override pub...
CellStyle style = poiCell.getCellStyle(); if (style == null) { style = poiCell.getRow() .getSheet() .getWorkbook() .createCellStyle(); poiCell.setCellStyle(style); } DataFormat dataF...
332
128
460
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/excel/converter/EnumConverter.java
EnumConverter
convertForWrite
class EnumConverter implements ConverterExcelOption { @SuppressWarnings("all") private final Class<? extends Enum> type; @Override public Object convertForWrite(Object val, ExcelHeader header) {<FILL_FUNCTION_BODY>} @Override @SuppressWarnings("all") public Object convertForRead(Object va...
if (val instanceof EnumDict) { return ((EnumDict<?>) val).getI18nMessage(LocaleUtils.current()); } if (val instanceof Enum) { return ((Enum<?>) val).name(); } return val;
236
76
312
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/excel/easyexcel/ExcelReadDataListener.java
ExcelReadDataListener
of
class ExcelReadDataListener<T> extends AnalysisEventListener<T> { private FluxSink<RowResult<T>> sink; public ExcelReadDataListener(FluxSink<RowResult<T>> sink) { this.sink = sink; } public static <T> Flux<RowResult<T>> of(InputStream fileInputStream, Class<T> clazz) {<FILL_FUNCTION_BODY>} ...
return Flux.create(sink -> { EasyExcel.read(fileInputStream, clazz, new ExcelReadDataListener<>(sink)).sheet().doRead(); });
301
48
349
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/file/FileEntity.java
FileEntity
of
class FileEntity extends GenericEntity<String> implements RecordCreationEntity { @Column(nullable = false) private String name; @Column(nullable = false) private String extension; @Column(nullable = false) private Long length; @Column(nullable = false, length = 32) private String md5...
FileEntity fileEntity = new FileEntity().copyFrom(fileInfo); fileEntity.setStoragePath(storagePath); fileEntity.setServerNodeId(serverNodeId); return fileEntity;
380
52
432
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/file/FileInfo.java
FileInfo
hasOption
class FileInfo { public static final String OTHER_ACCESS_KEY = "accessKey"; private String id; private String name; private String extension; private long length; private String md5; private String sha256; private long createTime; private String creatorId; private FileO...
if (options == null) { return false; } for (FileOption fileOption : options) { if (fileOption == option) { return true; } } return false;
467
58
525
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/file/FileManagerStorageService.java
FileManagerStorageService
saveFile
class FileManagerStorageService implements FileStorageService { private final FileManager fileManager; @Override public Mono<String> saveFile(FilePart filePart) { return fileManager .saveFile(filePart, FileOption.publicAccess) .map(FileInfo::getAccessUrl); } @Over...
return fileManager .saveFile(IDGenerator.RANDOM.generate() + "." + fileType, DataBufferUtils .readInputStream( () -> inputStream, DefaultDataBufferFactory.sharedInstance, ...
118
104
222
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/file/web/FileManagerController.java
FileManagerController
read
class FileManagerController { private final FileManager fileManager; @PostMapping("/upload") @Authorize(merge = false) @Operation(summary = "上传文件") public Mono<FileInfo> upload(@RequestPart("file") Mono<FilePart> partMono) { return partMono.flatMap(fileManager::saveFile); } @GetMa...
if (fileId.contains(".")) { fileId = fileId.substring(0, fileId.indexOf(".")); } return exchange .getResponse() .writeWith(fileManager .read(fileId, ctx -> { Mono<Void> before; ...
229
618
847
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/io-component/src/main/java/org/jetlinks/community/io/utils/FileUtils.java
FileUtils
dataBufferToInputStream
class FileUtils { public static String getExtension(String url) { url = HttpUtils.urlDecode(url); if (url.contains("?")) { url = url.substring(0, url.lastIndexOf("?")); } if (url.contains("#")) { url = url.substring(0, url.lastIndexOf("#")); } ...
NettyDataBufferFactory factory = new NettyDataBufferFactory(ByteBufAllocator.DEFAULT); return DataBufferUtils .join(dataBufferFlux .map(buffer -> { if (buffer instanceof NettyDataBuffer) { return buffer; ...
1,091
126
1,217
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/logging-component/src/main/java/org/jetlinks/community/logging/access/AccessLoggingTranslator.java
AccessLoggingTranslator
translate
class AccessLoggingTranslator { private final ApplicationEventPublisher eventPublisher; private final LoggingProperties properties; public AccessLoggingTranslator(ApplicationEventPublisher eventPublisher, LoggingProperties properties) { this.eventPublisher = eventPublisher; this.propertie...
for (String pathExclude : properties.getAccess().getPathExcludes()) { if (TopicUtils.match(pathExclude, event.getLogger().getUrl())) { return; } } eventPublisher.publishEvent(SerializableAccessLog.of(event.getLogger()));
113
78
191
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/logging-component/src/main/java/org/jetlinks/community/logging/access/SerializableAccessLog.java
SerializableAccessLog
of
class SerializableAccessLog implements Serializable { /** * 日志id */ @Schema(description = "日志ID") private String id; /** * 访问的操作 * * @see AccessLogger#value() */ @Schema(description = "操作") private String action; /** * 描述 * * @see AccessLogger#...
SerializableAccessLog accessLog = FastBeanCopier.copy(info, new SerializableAccessLog(), "parameters", "method", "target", "exception"); accessLog.setMethod(info.getMethod().getName()); accessLog.setTarget(info.getTarget().getName()); //移除敏感请求头 accessLog.getHttpHeaders().remove(...
628
305
933
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/logging-component/src/main/java/org/jetlinks/community/logging/event/handler/SystemLoggerEventHandler.java
SystemLoggerEventHandler
acceptAccessLoggerInfo
class SystemLoggerEventHandler { private final EventBus eventBus; private final ElasticSearchService elasticSearchService; public SystemLoggerEventHandler(ElasticSearchService elasticSearchService, ElasticSearchIndexManager indexManager, ...
eventBus .publish("/logging/system/" + info.getName().replace(".", "/") + "/" + (info.getLevel().toLowerCase()), info) .subscribe(); elasticSearchService.commit(LoggerIndexProvider.SYSTEM, Mono.just(info)) .subscribe();
322
75
397
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/logging-component/src/main/java/org/jetlinks/community/logging/logback/SystemLoggingAppender.java
SystemLoggingAppender
append
class SystemLoggingAppender extends UnsynchronizedAppenderBase<ILoggingEvent> { public static ApplicationEventPublisher publisher; public static final Map<String, String> staticContext = new ConcurrentHashMap<>(); @Override protected void append(ILoggingEvent event) {<FILL_FUNCTION_BODY>} }
if (publisher == null) { return; } StackTraceElement element = event.getCallerData()[0]; IThrowableProxy proxies = event.getThrowableProxy(); String message = event.getFormattedMessage(); String stack; StringJoiner joiner = new StringJoiner("\n", me...
87
898
985
<methods>public void <init>() ,public void addFilter(Filter<ch.qos.logback.classic.spi.ILoggingEvent>) ,public void clearAllFilters() ,public void doAppend(ch.qos.logback.classic.spi.ILoggingEvent) ,public List<Filter<ch.qos.logback.classic.spi.ILoggingEvent>> getCopyOfAttachedFiltersList() ,public ch.qos.logback.core....
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/http-component/src/main/java/org/jetlinks/community/network/http/DefaultHttpRequestMessage.java
DefaultHttpRequestMessage
setBody
class DefaultHttpRequestMessage implements HttpRequestMessage { //消息体 private ByteBuf payload; private String url; //请求方法 private HttpMethod method; //请求头 private List<Header> headers = new ArrayList<>(); //参数 private Map<String, String> queryParameters = new HashMap<>(); /...
if (body instanceof ByteBuf) { setPayload(((ByteBuf) body)); } else if (body instanceof String) { setPayload(Unpooled.wrappedBuffer(((String) body).getBytes())); } else if (body instanceof byte[]) { setPayload(Unpooled.wrappedBuffer(((byte[]) body))); ...
207
261
468
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/http-component/src/main/java/org/jetlinks/community/network/http/VertxWebUtils.java
VertxWebUtils
getIpAddr
class VertxWebUtils { static final String[] ipHeaders = { "X-Forwarded-For", "X-Real-IP", "Proxy-Client-IP", "WL-Proxy-Client-IP" }; /** * 获取请求客户端的真实ip地址 * * @param request 请求对象 * @return ip地址 */ public static String getIpAddr(HttpServerRequest ...
for (String ipHeader : ipHeaders) { String ip = request.getHeader(ipHeader); if (!StringUtils.isEmpty(ip) && !ip.contains("unknown")) { return ip; } } return Optional.ofNullable(request.remoteAddress()) .map(SocketAddress::host) ...
131
91
222
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/http-component/src/main/java/org/jetlinks/community/network/http/device/AsyncHttpExchangeMessage.java
AsyncHttpExchangeMessage
print
class AsyncHttpExchangeMessage implements HttpExchangeMessage { private static final AtomicReferenceFieldUpdater<AsyncHttpExchangeMessage, Boolean> RESPONDED = AtomicReferenceFieldUpdater.newUpdater(AsyncHttpExchangeMessage.class, Boolean.class, "responded"); private final HttpExchange exchange; ...
StringBuilder builder = new StringBuilder(); builder.append(getMethod()).append(" ").append(getPath()); if (!CollectionUtils.isEmpty(getQueryParameters())) { builder.append("?") .append(getQueryParameters() .entrySet().stream() ...
689
549
1,238
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/http-component/src/main/java/org/jetlinks/community/network/http/device/HttpDeviceSession.java
HttpDeviceSession
send
class HttpDeviceSession implements DeviceSession { private final DeviceOperator operator; private final InetSocketAddress address; @Setter private WebSocketExchange websocket; private long lastPingTime = System.currentTimeMillis(); //默认永不超时 private long keepAliveTimeOutMs = -1; pub...
if(websocket==null){ return Reactors.ALWAYS_FALSE; } if (encodedMessage instanceof WebSocketMessage) { return websocket .send(((WebSocketMessage) encodedMessage)) .thenReturn(true); } else { return websocket ...
494
116
610
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/http-component/src/main/java/org/jetlinks/community/network/http/device/HttpServerDeviceGatewayProvider.java
HttpServerDeviceGatewayProvider
reloadDeviceGateway
class HttpServerDeviceGatewayProvider implements DeviceGatewayProvider { private final NetworkManager networkManager; private final DeviceRegistry registry; private final DeviceSessionManager sessionManager; private final DecodedClientMessageHandler clientMessageHandler; private final ProtocolSu...
HttpServerDeviceGateway deviceGateway = ((HttpServerDeviceGateway) gateway); String networkId = properties.getChannelId(); //网络组件发生了变化 if(!Objects.equals(networkId, deviceGateway.httpServer.getId())){ return gateway .shutdown() .then(this ...
495
170
665
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/http-component/src/main/java/org/jetlinks/community/network/http/device/HttpServerExchangeMessage.java
HttpServerExchangeMessage
response
class HttpServerExchangeMessage implements HttpExchangeMessage { AtomicReference<Boolean> responded = new AtomicReference<>(false); MultiPart multiPart; public HttpServerExchangeMessage(HttpExchange exchange, ByteBuf payload, Mult...
return Mono .defer(() -> { if (!responded.getAndSet(true) && !exchange.isClosed()) { if (log.isDebugEnabled()) { log.debug("响应HTTP请求:\n{}", message.print()); } return exchange.response(message); ...
430
95
525
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/http-component/src/main/java/org/jetlinks/community/network/http/device/WebSocketDeviceSession.java
WebSocketDeviceSession
copy
class WebSocketDeviceSession implements DeviceSession { @Getter @Setter private volatile DeviceOperator operator; @Setter private WebSocketExchange exchange; private final long connectTime = System.currentTimeMillis(); private Duration keepAliveTimeout; public WebSocketDeviceSession...
WebSocketDeviceSession session = new WebSocketDeviceSession(operator, exchange); session.setKeepAliveTimeout(keepAliveTimeout); return session;
577
42
619
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/http-component/src/main/java/org/jetlinks/community/network/http/server/vertx/DefaultHttpServerProvider.java
DefaultHttpServerProvider
initServer
class DefaultHttpServerProvider implements NetworkProvider<HttpServerConfig> { private final CertificateManager certificateManager; private final Vertx vertx; @Getter @Setter private HttpServerOptions template = new HttpServerOptions(); public DefaultHttpServerProvider(CertificateManager cer...
int numberOfInstance = Math.max(1, config.getInstance()); List<HttpServer> instances = new ArrayList<>(numberOfInstance); return convert(config) .map(options -> { //利用多线程处理请求 for (int i = 0; i < numberOfInstance; i++) { instances.a...
822
272
1,094
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/http-component/src/main/java/org/jetlinks/community/network/http/server/vertx/VertxHttpServer.java
VertxHttpServer
createRoute
class VertxHttpServer implements HttpServer { private Collection<io.vertx.core.http.HttpServer> httpServers; private HttpServerConfig config; private String id; private final Topic<FluxSink<HttpExchange>> route = Topic.createRoot(); private final Topic<FluxSink<WebSocketExchange>> websocketRoute...
return Flux.create(sink -> { Disposable.Composite disposable = Disposables.composite(); for (String urlPattern : urlPatterns) { String pattern = Stream .of(urlPattern.split("/")) .map(str -> { //处理路径变量,如: /d...
1,233
286
1,519
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/http-component/src/main/java/org/jetlinks/community/network/http/server/vertx/VertxWebSocketExchange.java
VertxWebSocketExchange
send
class VertxWebSocketExchange implements WebSocketExchange { private final ServerWebSocket serverWebSocket; private final InetSocketAddress address; private final Sinks.Many<WebSocketMessage> sink = Reactors.createMany(); private final Map<String, Object> attributes = new ConcurrentHashMap<>(); ...
ByteBuf payload = webSocketMessage.getPayload(); return this .doWrite(handler -> { switch (webSocketMessage.getType()) { case TEXT: serverWebSocket.writeTextMessage(webSocketMessage.payloadAsString(), handler); ...
1,695
192
1,887
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/mqtt-component/src/main/java/org/jetlinks/community/network/mqtt/client/MqttClientProvider.java
MqttClientProvider
convert
class MqttClientProvider implements NetworkProvider<MqttClientProperties> { private final Vertx vertx; private final CertificateManager certificateManager; private final Environment environment; @Getter @Setter private MqttClientOptions template = new MqttClientOptions(); public MqttCl...
MqttClientOptions options = FastBeanCopier.copy(config, new MqttClientOptions(template)); String clientId = String.valueOf(config.getClientId()); String username = config.getUsername(); String password = config.getPassword(); options.setClientId(clientId); options.se...
1,009
207
1,216
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/mqtt-component/src/main/java/org/jetlinks/community/network/mqtt/gateway/device/MqttClientDeviceGateway.java
MqttClientDeviceGateway
reload
class MqttClientDeviceGateway extends AbstractDeviceGateway { final MqttClient mqttClient; private final DeviceRegistry registry; private Mono<ProtocolSupport> protocol; private Mono<DeviceMessageCodec> codecMono; private final DeviceGatewayHelper helper; private final Map<RouteKey, Tuple2...
return this .getProtocol() .flatMap(support -> support .getRoutes(DefaultTransport.MQTT) .filter(MqttRoute.class::isInstance) .cast(MqttRoute.class) .collectList() .doOnEach(ReactiveLogger ...
1,359
168
1,527
<methods>public void <init>(java.lang.String) ,public final void doOnShutdown(reactor.core.Disposable) ,public final void doOnStateChange(BiConsumer<org.jetlinks.community.gateway.GatewayState,org.jetlinks.community.gateway.GatewayState>) ,public final java.lang.String getId() ,public final org.jetlinks.community.gatew...
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/mqtt-component/src/main/java/org/jetlinks/community/network/mqtt/gateway/device/MqttClientDeviceGatewayProvider.java
MqttClientDeviceGatewayProvider
createDeviceGateway
class MqttClientDeviceGatewayProvider implements DeviceGatewayProvider { private final NetworkManager networkManager; private final DeviceRegistry registry; private final DeviceSessionManager sessionManager; private final DecodedClientMessageHandler clientMessageHandler; private final ProtocolSu...
return networkManager .<MqttClient>getNetwork(getNetworkType(), properties.getChannelId()) .map(mqttClient -> { String protocol = properties.getProtocol(); return new MqttClientDeviceGateway(properties.getId(), ...
554
123
677
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/mqtt-component/src/main/java/org/jetlinks/community/network/mqtt/gateway/device/MqttServerDeviceGatewayProvider.java
MqttServerDeviceGatewayProvider
createDeviceGateway
class MqttServerDeviceGatewayProvider implements DeviceGatewayProvider { private final NetworkManager networkManager; private final DeviceRegistry registry; private final DeviceSessionManager sessionManager; private final DecodedClientMessageHandler messageHandler; private final ProtocolSupport...
return networkManager .<MqttServer>getNetwork(getNetworkType(), properties.getChannelId()) .map(mqttServer -> new MqttServerDeviceGateway( properties.getId(), registry, sessionManager, mqttServer, messageHa...
535
90
625
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/mqtt-component/src/main/java/org/jetlinks/community/network/mqtt/gateway/device/session/MqttClientSession.java
MqttClientSession
isAlive
class MqttClientSession implements DeviceSession { @Getter private final String id; @Getter private final DeviceOperator operator; @Getter @Setter private MqttClient client; private final long connectTime = System.currentTimeMillis(); private long lastPingTime = System.currentTim...
return client.isAlive() && (keepAliveTimeout <= 0 || System.currentTimeMillis() - lastPingTime < keepAliveTimeout);
570
40
610
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/mqtt-component/src/main/java/org/jetlinks/community/network/mqtt/gateway/device/session/MqttConnectionSession.java
MqttConnectionSession
replaceWith
class MqttConnectionSession implements DeviceSession, ReplaceableDeviceSession { @Getter @Generated private final String id; @Getter @Generated private final DeviceOperator operator; @Getter @Generated private final Transport transport; @Getter @Generated private Mqtt...
if (session instanceof MqttConnectionSession) { MqttConnectionSession connectionSession = ((MqttConnectionSession) session); if (!this.connection.equals(connectionSession.connection)) { this.connection.close().subscribe(); } this.connection = conn...
739
78
817
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/mqtt-component/src/main/java/org/jetlinks/community/network/mqtt/gateway/device/session/UnknownDeviceMqttClientSession.java
UnknownDeviceMqttClientSession
send
class UnknownDeviceMqttClientSession implements DeviceSession { @Getter private final String id; private final MqttClient client; private final DeviceGatewayMonitor monitor; private Duration keepAliveTimeout; public UnknownDeviceMqttClientSession(String id, ...
if (encodedMessage instanceof MqttMessage) { return client .publish(((MqttMessage) encodedMessage)) .doOnSuccess(ignore->monitor.sentMessage()) .thenReturn(true); } return Mono.error(new UnsupportedOperationException("unsupported messa...
415
88
503
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/mqtt-component/src/main/java/org/jetlinks/community/network/mqtt/server/vertx/DefaultVertxMqttServerProvider.java
DefaultVertxMqttServerProvider
getConfigMetadata
class DefaultVertxMqttServerProvider implements NetworkProvider<VertxMqttServerProperties> { private final CertificateManager certificateManager; private final Vertx vertx; @Getter @Setter private MqttServerOptions template = new MqttServerOptions(); public DefaultVertxMqttServerProvider(Cert...
return new DefaultConfigMetadata() .add("id", "id", "", new StringType()) .add("host", "本地地址", "", new StringType()) .add("port", "本地端口", "", new IntType()) .add("publicHost", "公网地址", "", new StringType()) .add("publicPort", "公网端口", "", new IntType()...
1,048
170
1,218
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/mqtt-component/src/main/java/org/jetlinks/community/network/mqtt/server/vertx/VertxMqttConnection.java
VertxMqttAuth
equals
class VertxMqttAuth implements MqttAuth { @Override public String getUsername() { return endpoint.auth().getUsername(); } @Override public String getPassword() { return endpoint.auth().getPassword(); } } private int nextMessageId() { ...
if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; VertxMqttConnection that = (VertxMqttConnection) o; return Objects.equals(endpoint, that.endpoint);
158
72
230
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/mqtt-component/src/main/java/org/jetlinks/community/network/mqtt/server/vertx/VertxMqttServer.java
VertxMqttServer
setMqttServer
class VertxMqttServer implements MqttServer { private final Sinks.Many<MqttConnection> sink = Reactors.createMany(5 * 1024, false); private final Map<String, List<Sinks.Many<MqttConnection>>> sinks = new NonBlockingHashMap<>(); private Collection<io.vertx.mqtt.MqttServer> mqttServer; private...
if (this.mqttServer != null && !this.mqttServer.isEmpty()) { shutdown(); } this.mqttServer = mqttServer; for (io.vertx.mqtt.MqttServer server : this.mqttServer) { server .exceptionHandler(error -> { log.error(error.getMessage()...
947
139
1,086
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/network-core/src/main/java/org/jetlinks/community/network/DefaultNetworkManager.java
DefaultNetworkManager
getNetwork
class DefaultNetworkManager implements NetworkManager, BeanPostProcessor, CommandLineRunner { private final NetworkConfigManager configManager; private final Map<String, ReactiveCacheContainer<String, Network>> store = new ConcurrentHashMap<>(); private final Map<String, NetworkProvider<Object>> provider...
ReactiveCacheContainer<String, Network> networkMap = getNetworkStore(type); return networkMap .computeIfAbsent(id, (key) -> handleConfig(NetworkType.of(type), key, this::doCreate)) .map(n -> (T) n);
1,546
73
1,619
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/network-core/src/main/java/org/jetlinks/community/network/resource/DefaultNetworkResourceUser.java
DefaultNetworkResourceUser
getUsedResources
class DefaultNetworkResourceUser implements NetworkResourceUser { private final NetworkConfigManager configManager; private final NetworkManager networkManager; @Override public Flux<NetworkResource> getUsedResources() {<FILL_FUNCTION_BODY>} }
return configManager .getAllConfigs() .flatMap(conf -> networkManager .getProvider(conf.getType()) .map(provider -> provider .createConfig(conf) .onErrorResume(err -> Mono.empty())) .orElse(Mono.empt...
64
206
270
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/network-core/src/main/java/org/jetlinks/community/network/resource/NetworkResource.java
NetworkResource
of
class NetworkResource implements Serializable { private static final long serialVersionUID = 1L; /** * 网卡Host信息,如: 192.168.1.10 */ private String host; /** * 说明 */ private String description; /** * 端口信息,key为协议,如TCP,UDP. */ private Map<NetworkTransport, Set<In...
NetworkResource resource = new NetworkResource(); resource.setHost(host); if (ports != null && ports.length > 0) { resource.withPorts(NetworkTransport.TCP, Arrays.asList(ports)); } return resource;
1,287
68
1,355
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/network-core/src/main/java/org/jetlinks/community/network/resource/cluster/AbstractNetworkResourceManager.java
AbstractNetworkResourceManager
getAliveResources
class AbstractNetworkResourceManager implements NetworkResourceManager { private final List<NetworkResourceUser> resourceUsers; public AbstractNetworkResourceManager(List<NetworkResourceUser> resourceUser) { this.resourceUsers = resourceUser; } @Override public final Flux<NetworkResource>...
Mono<Map<String, List<NetworkResource>>> usedMapping = this .getLocalUsedResources() .collect(Collectors.groupingBy(NetworkResource::getHost)) .cache(); return this .getLocalAllResources() .map(NetworkResource::copy) .flatMap(reso...
158
172
330
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/network-core/src/main/java/org/jetlinks/community/network/resource/cluster/NetworkResourceProperties.java
NetworkResourceProperties
parseResources
class NetworkResourceProperties { private List<String> resources = new ArrayList<>(); public List<NetworkResource> parseResources() {<FILL_FUNCTION_BODY>} private List<Integer> getPorts(String port) { String[] ports = port.split("-"); if (ports.length == 1) { return Collection...
Map<String, NetworkResource> info = new LinkedHashMap<>(); for (String resource : resources) { NetworkTransport protocol = null; if (resource.contains("/")) { protocol = NetworkTransport.valueOf(resource .su...
233
363
596
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/network-core/src/main/java/org/jetlinks/community/network/security/DefaultCertificate.java
DefaultCertificate
initPfxKey
class DefaultCertificate implements Certificate { @Getter private final String id; @Getter private final String name; private KeyStoreHelper keyHelper; private KeyStoreHelper trustHelper; private static final X509Certificate[] EMPTY = new X509Certificate[0]; public DefaultCertific...
PfxOptions options = new PfxOptions(); options.setValue(Buffer.buffer(keys)); options.setPassword(password); keyHelper = KeyStoreHelper.create((KeyCertOptions) options); return this;
1,162
59
1,221
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/network-core/src/main/java/org/jetlinks/community/network/utils/BytesUtils.java
BytesUtils
lowBytesToInt
class BytesUtils { /** * 高位字节数组转int,低字节在前. * ------------------------------------------- * | 0-7位 | 8-16位 | 17-23位 | 24-31位 | * ------------------------------------------- * * @param src 字节数组 * @return int值 */ public static int highBytesToInt(byte[] src) { ...
int n = 0; len = Math.min(len, 4); for (int i = 0; i < len; i++) { int left = i * 8; n += ((src[offset + len - i - 1] & 0xFF) << left); } return n;
1,530
83
1,613
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/TcpMessage.java
TcpMessage
toString
class TcpMessage implements EncodedMessage { private ByteBuf payload; @Override public String toString() {<FILL_FUNCTION_BODY>} }
StringBuilder builder = new StringBuilder(); if (ByteBufUtil.isText(payload, StandardCharsets.UTF_8)) { builder.append(payloadAsString()); } else { ByteBufUtil.appendPrettyHexDump(builder, payload); } return builder.toString();
46
82
128
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/client/VertxTcpClient.java
VertxTcpClient
shutdown
class VertxTcpClient implements TcpClient { public volatile NetClient client; public NetSocket socket; volatile PayloadParser payloadParser; @Getter private final String id; @Setter private long keepAliveTimeoutMs = Duration.ofMinutes(10).toMillis(); private volatile long lastKeepA...
if (socket == null) { return; } log.debug("tcp client [{}] disconnect", getId()); synchronized (this) { if (null != client) { execute(client::close); client = null; } if (null != socket) { ex...
1,343
186
1,529
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/gateway/device/TcpDeviceSession.java
TcpDeviceSession
equals
class TcpDeviceSession implements DeviceSession { @Getter @Setter private DeviceOperator operator; @Setter private TcpClient client; @Getter private final Transport transport; private long lastPingTime = System.currentTimeMillis(); private final long connectTime = System.curren...
if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TcpDeviceSession session = (TcpDeviceSession) o; return Objects.equals(client, session.client);
631
65
696
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/gateway/device/TcpServerDeviceGateway.java
TcpConnection
checkLegality
class TcpConnection implements DeviceGatewayContext { final TcpClient client; final AtomicReference<DeviceSession> sessionRef = new AtomicReference<>(); final InetSocketAddress address; Disposable legalityChecker; TcpConnection(TcpClient client) { this.client = clien...
//超过时间还未获取到任何设备则认为连接不合法,自动断开连接 if ((sessionRef.get() instanceof UnknownTcpDeviceSession)) { log.info("tcp [{}] connection is illegal, close it.", address); try { client.disconnect(); } catch (Throwable ignore) { ...
1,035
87
1,122
<methods>public void <init>(java.lang.String) ,public final void doOnShutdown(reactor.core.Disposable) ,public final void doOnStateChange(BiConsumer<org.jetlinks.community.gateway.GatewayState,org.jetlinks.community.gateway.GatewayState>) ,public final java.lang.String getId() ,public final org.jetlinks.community.gatew...
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/gateway/device/TcpServerDeviceGatewayProvider.java
TcpServerDeviceGatewayProvider
createDeviceGateway
class TcpServerDeviceGatewayProvider implements DeviceGatewayProvider { private final NetworkManager networkManager; private final DeviceRegistry registry; private final DeviceSessionManager sessionManager; private final DecodedClientMessageHandler messageHandler; private final ProtocolSupports...
return networkManager .<TcpServer>getNetwork(getNetworkType(), properties.getChannelId()) .map(mqttServer -> { String protocol = properties.getProtocol(); Assert.hasText(protocol, "protocol can not be empty"); return new TcpServerDeviceG...
531
132
663
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/parser/DefaultPayloadParserBuilder.java
DefaultPayloadParserBuilder
postProcessAfterInitialization
class DefaultPayloadParserBuilder implements PayloadParserBuilder, BeanPostProcessor { private final Map<PayloadParserType, PayloadParserBuilderStrategy> strategyMap = new ConcurrentHashMap<>(); public DefaultPayloadParserBuilder(){ register(new FixLengthPayloadParserBuilder()); register(new D...
if (bean instanceof PayloadParserBuilderStrategy) { register(((PayloadParserBuilderStrategy) bean)); } return bean;
284
37
321
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/parser/LengthFieldPayloadParserBuilder.java
LengthFieldPayloadParserBuilder
buildLazy
class LengthFieldPayloadParserBuilder implements PayloadParserBuilderStrategy { @Override public PayloadParserType getType() { return PayloadParserType.LENGTH_FIELD; } @Override @SneakyThrows public Supplier<PayloadParser> buildLazy(ValueObject config) {<FILL_FUNCTION_BODY>} }
//偏移量 int offset = config.getInt("offset") .orElse(0); //包长度 int len = config.getInt("length") .orElseGet(() -> config .getInt("to") .orElse(4) - offset); //是否为小端模式 ...
93
506
599
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/parser/strateies/DelimitedPayloadParserBuilder.java
DelimitedPayloadParserBuilder
createParser
class DelimitedPayloadParserBuilder extends VertxPayloadParserBuilder { @Override public PayloadParserType getType() { return PayloadParserType.DELIMITED; } @Override @SneakyThrows protected Supplier<RecordParser> createParser(ValueObject config) {<FILL_FUNCTION_BODY>} }
String delimited = config .getString("delimited") .map(String::trim) .orElseThrow(() -> new IllegalArgumentException("delimited can not be null")); if (delimited.startsWith("0x")) { byte[] hex = Hex.decodeHex(delimited.substring(2)); return...
95
145
240
<methods>public non-sealed void <init>() ,public Supplier<org.jetlinks.community.network.tcp.parser.PayloadParser> buildLazy(org.jetlinks.community.ValueObject) ,public abstract org.jetlinks.community.network.tcp.parser.PayloadParserType getType() <variables>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/parser/strateies/FixLengthPayloadParserBuilder.java
FixLengthPayloadParserBuilder
createParser
class FixLengthPayloadParserBuilder extends VertxPayloadParserBuilder { @Override public PayloadParserType getType() { return PayloadParserType.FIXED_LENGTH; } @Override protected Supplier<RecordParser> createParser(ValueObject config) {<FILL_FUNCTION_BODY>} }
int size = config.getInt("size") .orElseThrow(() -> new IllegalArgumentException("size can not be null")); return () -> RecordParser.newFixed(size);
87
50
137
<methods>public non-sealed void <init>() ,public Supplier<org.jetlinks.community.network.tcp.parser.PayloadParser> buildLazy(org.jetlinks.community.ValueObject) ,public abstract org.jetlinks.community.network.tcp.parser.PayloadParserType getType() <variables>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/parser/strateies/PipePayloadParser.java
PipePayloadParser
complete
class PipePayloadParser implements PayloadParser { private final static AtomicIntegerFieldUpdater<PipePayloadParser> CURRENT_PIPE = AtomicIntegerFieldUpdater.newUpdater(PipePayloadParser.class, "currentPipe"); private final Sinks.Many<Buffer> sink = Reactors.createMany(); private final List<BiCon...
CURRENT_PIPE.set(this, 0); if (recordParser != null) { firstInit.accept(recordParser); } if (!this.result.isEmpty()) { Buffer buffer = Buffer.buffer(); for (Buffer buf : this.result) { buffer.appendBuffer(buf); } ...
1,010
122
1,132
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/parser/strateies/ScriptPayloadParserBuilder.java
ScriptPayloadParserBuilder
buildLazy
class ScriptPayloadParserBuilder implements PayloadParserBuilderStrategy { @Override public PayloadParserType getType() { return PayloadParserType.SCRIPT; } @Override @SneakyThrows public Supplier<PayloadParser> buildLazy(ValueObject config) {<FILL_FUNCTION_BODY>} }
String script = config.getString("script") .orElseThrow(() -> new IllegalArgumentException("script不能为空")); String lang = config.getString("lang") .orElse("js"); CompiledScript compiledScript = Scripts .getFactory(lang) ...
88
160
248
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/parser/strateies/VertxPayloadParserBuilder.java
RecordPayloadParser
reset
class RecordPayloadParser implements PayloadParser { private final Supplier<RecordParser> recordParserSupplier; private final Sinks.Many<Buffer> sink = Reactors.createMany(); private RecordParser recordParser; public RecordPayloadParser(Supplier<RecordParser> recordParserSupplier) { ...
this.recordParser = recordParserSupplier.get(); this.recordParser.handler(payload -> { sink.emitNext(payload, Reactors.emitFailureHandler()); });
210
51
261
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/server/DefaultTcpServerProvider.java
DefaultTcpServerProvider
getConfigMetadata
class DefaultTcpServerProvider implements NetworkProvider<TcpServerProperties> { private final CertificateManager certificateManager; private final Vertx vertx; private final PayloadParserBuilder payloadParserBuilder; @Getter @Setter private NetServerOptions template = new NetServerOptions()...
return new DefaultConfigMetadata() .add("host", "本地地址", "", new StringType()) .add("port", "本地端口", "", new IntType()) .add("publicHost", "公网地址", "", new StringType()) .add("publicPort", "公网端口", "", new IntType()) .add("certId", "CA证书", "", new StringT...
1,031
162
1,193
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/server/VertxTcpServer.java
VertxTcpServer
acceptTcpConnection
class VertxTcpServer implements TcpServer { Collection<NetServer> tcpServers; private Supplier<PayloadParser> parserSupplier; @Setter private long keepAliveTimeout = Duration.ofMinutes(10).toMillis(); @Getter private final String id; private final Sinks.Many<TcpClient> sink = Reactors....
if (sink.currentSubscriberCount() == 0) { log.warn("not handler for tcp client[{}]", socket.remoteAddress()); socket.close(); return; } VertxTcpClient client = new VertxTcpClient(id + "_" + socket.remoteAddress()); client.setKeepAliveTimeoutMs(keepAli...
621
230
851
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/AbstractNotifier.java
AbstractNotifier
send
class AbstractNotifier<T extends Template> implements Notifier<T> { private final TemplateManager templateManager; @Override @Nonnull public Mono<Void> send(@Nonnull String templateId, @Nonnull Values context) {<FILL_FUNCTION_BODY>} }
return templateManager .getTemplate(getType(), templateId) .switchIfEmpty(Mono.error(new UnsupportedOperationException("模版不存在:" + templateId))) .flatMap(tem -> send((T) tem, context));
78
65
143
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/DefaultNotifierManager.java
DefaultNotifierManager
run
class DefaultNotifierManager implements NotifierManager, BeanPostProcessor, CommandLineRunner { private final Map<String, Map<String, NotifierProvider>> providers = new ConcurrentHashMap<>(); private Map<String, Notifier> notifiers = new ConcurrentHashMap<>(); private NotifyConfigManager configManager; ...
eventBus .subscribe( Subscription.builder() .subscriberId("notifier-loader") .topics("/_sys/notifier/reload") .justBroker() .build(), String.class ...
817
132
949
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/NotifierEventDispatcher.java
NotifierEventDispatcher
onEvent
class NotifierEventDispatcher<T extends Template> extends NotifierProxy<T> { private final EventBus eventBus; public NotifierEventDispatcher(EventBus eventBus, Notifier<T> target) { super(target); this.eventBus = eventBus; } @Override protected Mono<Void> onEvent(NotifierEvent eve...
// /notify/{notifierId}/success return eventBus .publish(String.join("/", "/notify", event.getNotifierId(), event.isSuccess() ? "success" : "error"), event.toSerializable()) .then();
111
65
176
<methods>public non-sealed void <init>() ,public Mono<java.lang.Void> close() ,public java.lang.String getNotifierId() ,public org.jetlinks.community.notify.Provider getProvider() ,public org.jetlinks.community.notify.NotifyType getType() ,public boolean isWrapperFor(Class<?>) ,public Mono<java.lang.Void> send(java.lan...
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/NotifierProxy.java
NotifierProxy
onSuccess
class NotifierProxy<T extends Template> implements Notifier<T> { private final Notifier<T> target; @Override public String getNotifierId() { return target.getNotifierId(); } @Nonnull @Override public NotifyType getType() { return target.getType(); } @Nonnull @...
return onEvent(NotifierEvent.builder() .success(true) .context(ctx.getAllValues()) .notifierId(getNotifierId()) .notifyType(getType()) .provider(getProvider()) .template(template) .build());
773
74
847
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/StaticTemplateManager.java
StaticTemplateManager
postProcessAfterInitialization
class StaticTemplateManager extends AbstractTemplateManager implements BeanPostProcessor { private StaticNotifyProperties properties; public StaticTemplateManager(StaticNotifyProperties properties) { this.properties = properties; } public void register(TemplateProvider provider) { sup...
if(bean instanceof TemplateProvider){ register(((TemplateProvider) bean)); } return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
167
48
215
<methods>public non-sealed void <init>() ,public Mono<? extends org.jetlinks.community.notify.template.Template> createTemplate(org.jetlinks.community.notify.NotifyType, org.jetlinks.community.notify.template.TemplateProperties) ,public Mono<? extends org.jetlinks.community.notify.template.Template> getTemplate(org.jet...
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/configuration/CompositeNotifyConfigManager.java
CompositeNotifyConfigManager
getNotifyConfig
class CompositeNotifyConfigManager implements NotifyConfigManager { private final List<NotifyConfigManager> managers; @Nonnull @Override public Mono<NotifierProperties> getNotifyConfig(@Nonnull NotifyType notifyType, @Nonnull String configId) {<FILL_F...
Mono<NotifierProperties> mono = null; for (NotifyConfigManager manager : managers) { if (mono == null) { mono = manager.getNotifyConfig(notifyType, configId); } else { mono = mono.switchIfEmpty(manager.getNotifyConfig(notifyType, configId)); ...
85
111
196
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/configuration/CompositeTemplateManager.java
CompositeTemplateManager
doWith
class CompositeTemplateManager implements TemplateManager { private final List<TemplateManager> managers; private <T> Mono<T> doWith(Function<TemplateManager, Mono<T>> executor) {<FILL_FUNCTION_BODY>} @Nonnull @Override public Mono<? extends Template> getTemplate(@Nonnull NotifyType type, @Nonnul...
Mono<T> mono = null; for (TemplateManager manager : managers) { if (mono == null) { mono = executor.apply(manager); } else { mono = mono.switchIfEmpty(executor.apply(manager)); } } return mono == null ? Mono.empty() :...
349
98
447
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/configuration/StaticNotifyProperties.java
StaticNotifyProperties
getTemplateProperties
class StaticNotifyProperties { private Map<String, List<NotifierProperties>> configs = new ConcurrentHashMap<>(); private Map<String, List<TemplateProperties>> templates = new ConcurrentHashMap<>(); public Optional<NotifierProperties> getNotifierProperties(NotifyType type,String id){ List<Notifie...
List<TemplateProperties> properties= templates.get(type.getId()); if(properties==null){ return Optional.empty(); } return properties .stream() .filter(prop-> { prop.setType(type.getId()); return Objects.equals(id,prop.g...
285
90
375
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/event/NotifierEvent.java
NotifierEvent
toSerializable
class NotifierEvent { private boolean success; @Nullable private Throwable cause; @Nonnull private String notifierId; @Nonnull private NotifyType notifyType; @Nonnull private Provider provider; @Nullable private String templateId; @Nullable private Template tem...
return SerializableNotifierEvent.builder() .success(success) .notifierId(notifierId) .notifyType(notifyType.getId()) .provider(provider.getId()) .templateId(templateId) .template(template) .context(context) .cause(c...
136
124
260
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/rule/NotifierTaskExecutorProvider.java
NotifierTaskExecutor
createProperties
class NotifierTaskExecutor extends FunctionTaskExecutor { private RuleNotifierProperties properties; public NotifierTaskExecutor(ExecutionContext context) { super("消息通知", context); this.properties = createProperties(); } @Override protected Publisher<Rul...
RuleNotifierProperties properties = FastBeanCopier.copy(context .getJob() .getConfiguration(), RuleNotifierProperties.class); properties.initVariable()...
392
59
451
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/rule/RuleNotifierProperties.java
RuleNotifierProperties
initVariable
class RuleNotifierProperties { private DefaultNotifyType notifyType; private String notifierId; private String templateId; private Map<String, Object> variables; public void initVariable() {<FILL_FUNCTION_BODY>} public Map<String, Object> createVariables(RuleData data) { Map<String...
if (MapUtils.isNotEmpty(variables)) { for (Map.Entry<String, Object> entry : variables.entrySet()) { Object value = entry.getValue(); if (value instanceof Collection) { List<VariableSource> sourceList = ((Collection<?>) value) ...
350
162
512
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/template/AbstractTemplate.java
AbstractTemplate
addVariable
class AbstractTemplate<Self extends AbstractTemplate<Self>> implements Template { private Map<String, VariableDefinition> variables; @Getter private String configId; public AbstractTemplate() { } public Self with(TemplateProperties properties) { if (this.variables == null) { ...
if (null == variables) { variables = new HashMap<>(); } variables.put(def.getId(), def);
574
36
610
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/template/AbstractTemplateManager.java
AbstractTemplateManager
createTemplate
class AbstractTemplateManager implements TemplateManager { protected final Map<String, Map<String, TemplateProvider>> providers = new ConcurrentHashMap<>(); protected final Map<String, Template> templates = new ConcurrentHashMap<>(); protected abstract Mono<TemplateProperties> getProperties(NotifyType ty...
return Mono.justOrEmpty(providers.get(type.getId())) .switchIfEmpty(Mono.error(() -> new UnsupportedOperationException("不支持的通知类型:" + prop.getType()))) .flatMap(map -> Mono .justOrEmpty(map.get(prop.getProvider())) .switchIfEmpt...
447
131
578
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/template/TemplateUtils.java
TemplateUtils
getVariables
class TemplateUtils { public static Set<String> getVariables(String templateText) { return getVariables(templateText, "${", "}"); } public static Set<String> getVariables(String templateText, String suffix, String prefix) {<FILL_FUNCTION_BODY>} public static String simpleRender(String templat...
final Set<String> variable = new LinkedHashSet<>(); TemplateParser parser = new TemplateParser(); parser.setTemplate(templateText); parser.setPrepareStartSymbol(suffix.toCharArray()); parser.setPrepareEndSymbol(prefix.toCharArray()); parser.parse(varName -> { ...
322
148
470
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/template/VariableDefinition.java
VariableDefinition
convertValue
class VariableDefinition { @Schema(description = "变量标识") @NotBlank private String id; @Schema(description = "变量名称") private String name; @Schema(description = "说明") private String description; /** * @see DataType#getId() * @see org.jetlinks.core.metadata.types.DoubleType ...
if (value == null) { value = defaultValue; } //必填 if (this.required && value == null) { throw new ValidationException(id, "error.template_var_required", this.getId(), this.getName()); } DataType dataType = lookupType(); String fmt = format...
1,059
336
1,395
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/corp/DingTalkMessageTemplate.java
DingTalkMessageTemplate
createUserIdList
class DingTalkMessageTemplate extends AbstractTemplate<DingTalkMessageTemplate> { public static final String USER_ID_LIST_KEY = "userIdList"; public static final String DEPARTMENT_ID_LIST_KEY = "departmentIdList"; /** * 应用ID */ @NotBlank private String agentId; /** * 接收者的useri...
return VariableSource .resolveValue(USER_ID_LIST_KEY, context.getAllValues(), relationPropertyPath) .map(String::valueOf) .filter(StringUtils::hasText) .defaultIfEmpty(userIdList == null ? "" : userIdList) .collect(Collectors.joining(","));
1,177
86
1,263
<methods>public void <init>() ,public final Optional<org.jetlinks.community.notify.template.VariableDefinition> getVariable(java.lang.String) ,public final Map<java.lang.String,org.jetlinks.community.notify.template.VariableDefinition> getVariables() ,public Map<java.lang.String,java.lang.Object> toMap() ,public org.je...
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/corp/DingTalkNotifier.java
DingTalkNotifier
filter
class DingTalkNotifier extends AbstractNotifier<DingTalkMessageTemplate> implements CommandSupport, ExchangeFilterFunction { private final WebClient client; private final DingTalkProperties properties; private volatile Mono<String> token; @Getter private final String notifierId; public Ding...
if (request.url().getPath().endsWith("gettoken")) { return next.exchange(request); } //自动填充access_token return this .getToken() .flatMap(token -> next .exchange( ClientRequest .from(request) ...
892
131
1,023
<methods>public non-sealed void <init>() ,public Mono<java.lang.Void> send(java.lang.String, org.jetlinks.core.Values) <variables>private final non-sealed org.jetlinks.community.notify.template.TemplateManager templateManager
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/corp/DingTalkNotifierProvider.java
DingTalkNotifierProvider
createNotifier
class DingTalkNotifierProvider implements NotifierProvider, TemplateProvider { private final WebClient.Builder clientBuilder; private final TemplateManager templateManager; public DingTalkNotifierProvider(TemplateManager templateManager, WebClient.Builder builder) { this.templateManager = templat...
return Mono.defer(() -> { DingTalkProperties dingTalkProperties = FastBeanCopier.copy(properties.getConfiguration(), new DingTalkProperties()); return Mono .just(new DingTalkNotifier( properties.getId(), clientBuilder, ValidatorUtils.tryValidate(dingT...
567
116
683
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/corp/request/GetAccessTokenRequest.java
GetAccessTokenRequest
execute
class GetAccessTokenRequest extends ApiRequest<Mono<AccessTokenResponse>> { private final String appKey; private final String appSecret; @Override public Mono<AccessTokenResponse> execute(WebClient client) {<FILL_FUNCTION_BODY>} }
return client .get() .uri("gettoken", uri -> uri .queryParam("appkey", appKey) .queryParam("appsecret", appSecret) .build()) .retrieve() .bodyToMono(AccessTokenResponse.class);
74
73
147
<methods>public non-sealed void <init>() ,public abstract Mono<org.jetlinks.community.notify.dingtalk.corp.response.AccessTokenResponse> execute(org.springframework.web.reactive.function.client.WebClient) <variables>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/corp/request/GetDepartmentRequest.java
GetDepartmentRequest
doRequest
class GetDepartmentRequest extends ApiRequest<Flux<CorpDepartment>> { private final String departmentId; private final boolean fetchChild; public GetDepartmentRequest() { this(null, true); } public GetDepartmentRequest(boolean fetchChild) { this(null, fetchChild); } @Ove...
return client .post() .uri("/topapi/v2/department/listsub") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .body(StringUtils.hasText(departmentId) ? BodyInserters.fromFormData("dept_id", departmentId) : BodyInserte...
262
247
509
<methods>public non-sealed void <init>() ,public abstract Flux<org.jetlinks.community.notify.dingtalk.corp.CorpDepartment> execute(org.springframework.web.reactive.function.client.WebClient) <variables>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/corp/request/GetUserAccessTokenRequest.java
GetUserAccessTokenRequest
execute
class GetUserAccessTokenRequest extends ApiRequest<Mono<AccessTokenResponse>> { private final String appKey; private final String appSecret; private final String code; @Override public Mono<AccessTokenResponse> execute(WebClient client) {<FILL_FUNCTION_BODY>} }
Map<String, Object> body = new HashMap<>(); body.put("clientId", appKey); body.put("clientSecret", appSecret); body.put("code", code); body.put("grantType", "authorization_code"); return client .post() .uri("https://api.dingtalk.com/v1.0/oauth2...
83
135
218
<methods>public non-sealed void <init>() ,public abstract Mono<org.jetlinks.community.notify.dingtalk.corp.response.AccessTokenResponse> execute(org.springframework.web.reactive.function.client.WebClient) <variables>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/corp/request/GetUserIdByUnionIdRequest.java
GetUserIdByUnionIdRequest
doRequest
class GetUserIdByUnionIdRequest extends ApiRequest<Mono<GetUserIdByUnionIdRequest.UserUnionInfoResponse>> { private final String unionId; @Override public Mono<UserUnionInfoResponse> execute(WebClient client) { return doRequest(client); } private Mono<UserUnionInfoResponse> doRequest(WebC...
Map<String, Object> body = new HashMap<>(); body.put("unionid", unionId); return client .post() .uri("/topapi/user/getbyunionid") .bodyValue(body) .retrieve() .bodyToMono(UserUnionInfoResponse.class) .doOnNext(rep -> { ...
232
128
360
<methods>public non-sealed void <init>() ,public abstract Mono<org.jetlinks.community.notify.dingtalk.corp.request.GetUserIdByUnionIdRequest.UserUnionInfoResponse> execute(org.springframework.web.reactive.function.client.WebClient) <variables>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/corp/request/GetUserInfoRequest.java
GetUserInfoRequest
doRequest
class GetUserInfoRequest extends ApiRequest<Mono<GetUserInfoRequest.UserInfoResponse>> { private final String accessToken; @Override public Mono<UserInfoResponse> execute(WebClient client) { return doRequest(client); } private Mono<UserInfoResponse> doRequest(WebClient client) {<FILL_FUNC...
return client .get() .uri("https://api.dingtalk.com/v1.0/contact/users/{unionId}", "me") .header("x-acs-dingtalk-access-token", accessToken) .retrieve() .bodyToMono(UserInfoResponse.class) .doOnNext(rep -> { if (rep.getUnio...
199
127
326
<methods>public non-sealed void <init>() ,public abstract Mono<org.jetlinks.community.notify.dingtalk.corp.request.GetUserInfoRequest.UserInfoResponse> execute(org.springframework.web.reactive.function.client.WebClient) <variables>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/corp/request/GetUserRequest.java
GetUserRequest
doRequest
class GetUserRequest extends ApiRequest<Flux<CorpUser>> { private final String departmentId; @Override public Flux<CorpUser> execute(WebClient client) { return this .doRequest(0, client) .flatMapIterable(Response::getList); } private Flux<Response> doRequest(int pa...
return client .post() .uri("/topapi/user/listsimple") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .body(BodyInserters .fromFormData("dept_id", departmentId) .with("cursor", String.valueOf(pageIndex)) ...
346
204
550
<methods>public non-sealed void <init>() ,public abstract Flux<org.jetlinks.community.notify.dingtalk.corp.CorpUser> execute(org.springframework.web.reactive.function.client.WebClient) <variables>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/corp/response/ApiResponse.java
ApiResponse
assertSuccess
class ApiResponse { @JsonProperty @JsonAlias("request_id") private String requestId; @JsonProperty @JsonAlias("errcode") private int errorCode; @JsonProperty @JsonAlias("errmsg") private String errorMessage; public boolean isSuccess() { return errorCode == 0; } ...
if (!isSuccess()) { throw new BusinessException("error.dingtalk_api_request_error", 500, errorMessage); }
119
40
159
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/robot/DingTalkRobotWebHookNotifier.java
DingTalkRobotWebHookNotifier
send
class DingTalkRobotWebHookNotifier extends AbstractNotifier<DingTalkWebHookTemplate> { @Getter private final String notifierId; private final String url; private final WebClient client; public DingTalkRobotWebHookNotifier(String notifierId, TemplateManager ...
return client .post() .uri(url) .contentType(MediaType.APPLICATION_JSON) .bodyValue(template.toJson(context.getAllValues())) .retrieve() .bodyToMono(String.class) .doOnNext(str -> { JSONObject response = JSON.pa...
447
139
586
<methods>public non-sealed void <init>() ,public Mono<java.lang.Void> send(java.lang.String, org.jetlinks.core.Values) <variables>private final non-sealed org.jetlinks.community.notify.template.TemplateManager templateManager
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/robot/DingTalkRobotWebHookNotifierProvider.java
DingTalkRobotWebHookNotifierProvider
createNotifier
class DingTalkRobotWebHookNotifierProvider implements NotifierProvider, TemplateProvider { private final WebClient client; private final TemplateManager templateManager; public DingTalkRobotWebHookNotifierProvider(TemplateManager templateManager, WebClient.Builder builder) { this.templateManager ...
return Mono.fromSupplier(() -> { String url = properties .getString("url") .filter(StringUtils::hasText) .orElseThrow(() -> new IllegalArgumentException("url can not be null")); return new DingTalkRobotWebHookNotifier( prop...
804
104
908
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/robot/DingTalkWebHookTemplate.java
At
toJson
class At { private List<String> atMobiles; private List<String> atUserIds; private boolean atAll; public At render(Template template, Map<String, Object> context) { return new At(template.render(atMobiles, context), template.render(atUserIds, contex...
JSONObject json = new JSONObject(); json.put("atMobiles", atMobiles); json.put("atUserIds", atUserIds); json.put("isAtAll", atAll); return json;
115
61
176
<methods>public void <init>() ,public final Optional<org.jetlinks.community.notify.template.VariableDefinition> getVariable(java.lang.String) ,public final Map<java.lang.String,org.jetlinks.community.notify.template.VariableDefinition> getVariables() ,public Map<java.lang.String,java.lang.Object> toMap() ,public org.je...
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-dingtalk/src/main/java/org/jetlinks/community/notify/dingtalk/web/DingTalkCorpNotifierController.java
DingTalkCorpNotifierController
getDepartmentUsers
class DingTalkCorpNotifierController { private final NotifierManager notifierManager; private final NotifyConfigManager notifyConfigManager; private final UserBindService userBindService; @GetMapping("/{configId}/departments") @Operation(summary = "获取企业部门信息") public Flux<CorpDepartment> getD...
return notifierManager .getNotifier(DefaultNotifyType.dingTalk, configId) .map(notifier -> notifier.unwrap(CommandSupport.class)) .flatMapMany(support -> support .execute(new GetDepartmentRequest(true)) .flatMap(department -> support.execute(n...
1,164
105
1,269
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-email/src/main/java/org/jetlinks/community/notify/email/embedded/DefaultEmailProperties.java
ConfigProperty
createJavaMailProperties
class ConfigProperty { private String name; private String value; private String description; } public Properties createJavaMailProperties() {<FILL_FUNCTION_BODY>
Properties properties = new Properties(); if (this.properties != null) { for (ConfigProperty property : this.properties) { properties.put(property.getName(), property.getValue()); } } if(ssl){ properties.putIfAbsent("mail.smtp.auth","...
51
109
160
<no_super_class>
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-email/src/main/java/org/jetlinks/community/notify/email/embedded/EmailTemplate.java
Attachment
getEmbeddedVariables
class Attachment { public static final String LOCATION_KEY = "location"; private String name; private String location; public static String locationKey(int index) { return "_attach_location_" + index; } } @Nonnull @Override protected List<Variabl...
List<VariableDefinition> variables = new ArrayList<>(); if (CollectionUtils.isEmpty(sendTo)) { variables.add( VariableDefinition .builder() .id(SEND_TO_KEY) .name("收件人") .expand(NotifyVariableBus...
105
307
412
<methods>public void <init>() ,public final Optional<org.jetlinks.community.notify.template.VariableDefinition> getVariable(java.lang.String) ,public final Map<java.lang.String,org.jetlinks.community.notify.template.VariableDefinition> getVariables() ,public Map<java.lang.String,java.lang.Object> toMap() ,public org.je...
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-sms/src/main/java/org/jetlinks/community/notify/sms/aliyun/AliyunSmsNotifier.java
AliyunSmsNotifier
getSmsSigns
class AliyunSmsNotifier extends AbstractNotifier<AliyunSmsTemplate> { private final IAcsClient client; private final int connectTimeout = 1000; private final int readTimeout = 5000; @Getter private String notifierId; private String domain = "dysmsapi.aliyuncs.com"; private String regionId...
return doQuerySmsSigns(new AtomicInteger(0), 50) .flatMapIterable(Function.identity()) .map(SmsSign::of) .as(FluxTracer.create("/aliyun/sms/sign")) .onErrorResume(err -> Mono.empty());
1,634
84
1,718
<methods>public non-sealed void <init>() ,public Mono<java.lang.Void> send(java.lang.String, org.jetlinks.core.Values) <variables>private final non-sealed org.jetlinks.community.notify.template.TemplateManager templateManager
jetlinks_jetlinks-community
jetlinks-community/jetlinks-components/notify-component/notify-sms/src/main/java/org/jetlinks/community/notify/sms/aliyun/AliyunSmsTemplate.java
AliyunSmsTemplate
getEmbeddedVariables
class AliyunSmsTemplate extends AbstractTemplate<AliyunSmsTemplate> { public static final String PHONE_NUMBER_KEY = "phoneNumber"; //签名名称 @NotBlank(message = "[signName]不能为空") private String signName; //模版编码 @NotBlank(message = "[code]不能为空") private String code; //为空时,则表示从变量中传入 /...
//指定了固定的收信人 if (StringUtils.hasText(phoneNumber)) { return Collections.emptyList(); } return Collections.singletonList( VariableDefinition .builder() .id(PHONE_NUMBER_KEY) .name("收信人") .description("...
459
150
609
<methods>public void <init>() ,public final Optional<org.jetlinks.community.notify.template.VariableDefinition> getVariable(java.lang.String) ,public final Map<java.lang.String,org.jetlinks.community.notify.template.VariableDefinition> getVariables() ,public Map<java.lang.String,java.lang.Object> toMap() ,public org.je...