use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class HttpPathConfigJsonBuilder method addPath.
public HttpPathConfigJsonBuilder addPath(String roboUnit, HttpMethod method, List<String> filters) {
HttpPathMethodDTO document = new HttpPathMethodDTO(roboUnit, method, filters);
paths.add(document);
return this;
}
use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class DatagramPathUtils method updateDatagramServerContextPaths.
public static void updateDatagramServerContextPaths(final RoboContext context, final ServerContext serverContext, final Collection<HttpPathMethodDTO> paths) {
final Map<PathHttpMethod, ServerPathConfig> resultPaths = paths.stream().map(e -> {
RoboReference<Object> reference = context.getReference(e.getRoboUnit());
return new ServerPathConfig(toPath(SystemPath.UNITS.getPath(), e.getRoboUnit()), reference, e.getMethod(), e.getCallbacks());
}).collect(Collectors.toMap(e -> new PathHttpMethod(e.getPath(), null), e -> e));
serverContext.addPaths(resultPaths);
}
use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class HttpPathUtils method readServerPathDTO.
/**
* parse json string to mutable path properties
*
* @param configurationJson
* configuration json
* @return return server path dto with method and possible properties
*/
public static HttpPathMethodDTO readServerPathDTO(String configurationJson) {
Class<HttpPathMethodDTO> clazz = HttpPathMethodDTO.class;
JsonReader jsonReader = new JsonReader(configurationJson);
JsonDocument document = jsonReader.read();
return ReflectUtils.createInstanceByClazzAndDescriptorAndJsonDocument(clazz, document);
}
use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class HttpPathUtils method updateHttpServerContextPaths.
public static void updateHttpServerContextPaths(final RoboContext context, final ServerContext serverContext, final Collection<HttpPathMethodDTO> paths) {
final Map<PathHttpMethod, ServerPathConfig> resultPaths = paths.stream().map(e -> {
RoboReference<Object> reference = context.getReference(e.getRoboUnit());
return HttpPathUtils.toHttpPathConfig(e, reference);
}).collect(Collectors.toMap(e -> new PathHttpMethod(e.getPath(), e.getMethod()), e -> e));
resultPaths.put(new PathHttpMethod(Utf8Constant.UTF8_SOLIDUS, HttpMethod.GET), new ServerPathConfig(Utf8Constant.UTF8_SOLIDUS, null, HttpMethod.GET));
serverContext.addPaths(resultPaths);
}
use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class JsonUtil method toJsonArrayServer.
public static <T> String toJsonArrayServer(List<T> list) {
return JsonElementStringBuilder.Builder().add(Utf8Constant.UTF8_SQUARE_BRACKET_LEFT).add(list.stream().map(e -> {
if (e instanceof ResponseAttributeDTO) {
ResponseAttributeDTO ra = (ResponseAttributeDTO) e;
switch(ra.getType()) {
case "java.util.ArrayList":
List<HttpPathMethodDTO> tmpList = JsonUtil.readPathConfig(HttpPathMethodDTO.class, ra.getValue());
ResponseAttributeListDTO tmpAttr = new ResponseAttributeListDTO();
tmpAttr.setId(ra.getId());
tmpAttr.setType(ra.getType());
tmpAttr.setValue(tmpList);
return ReflectUtils.createJson(tmpAttr);
default:
return ReflectUtils.createJson(e);
}
} else {
return ReflectUtils.createJson(e);
}
}).collect(Collectors.joining(Utf8Constant.UTF8_COMMA))).add(Utf8Constant.UTF8_SQUARE_BRACKET_RIGHT).build();
}
Aggregations