/** * Build a servlet DTO from a servlet info * @param info The servlet info * @return A servlet DTO */ public static ServletDTO build(final ServletInfo info, final int reason) { final ServletDTO dto = (reason != -1 ? new FailedServletDTO() : new ServletDTO()); BaseServletDTOBuilder.fill(dto, info); if ( reason != -1 ) { ((FailedServletDTO)dto).failureReason = reason; } dto.patterns = BuilderConstants.EMPTY_STRING_ARRAY; final MultipartConfig config = info.getMultipartConfig(); dto.multipartEnabled = config != null; if ( config != null ) { dto.multipartFileSizeThreshold = config.multipartThreshold; dto.multipartLocation = config.multipartLocation; dto.multipartMaxFileSize = config.multipartMaxFileSize; dto.multipartMaxRequestSize = config.multipartMaxRequestSize; } return dto; } }
/** * Build a servlet DTO from a servlet info * @param info The servlet info * @return A servlet DTO */ public static ServletDTO build(final ServletInfo info, final int reason) { final ServletDTO dto = (reason != -1 ? new FailedServletDTO() : new ServletDTO()); BaseServletDTOBuilder.fill(dto, info); if ( reason != -1 ) { ((FailedServletDTO)dto).failureReason = reason; } dto.patterns = BuilderConstants.EMPTY_STRING_ARRAY; final MultipartConfig config = info.getMultipartConfig(); dto.multipartEnabled = config != null; if ( config != null ) { dto.multipartFileSizeThreshold = config.multipartThreshold; dto.multipartLocation = config.multipartLocation; dto.multipartMaxFileSize = config.multipartMaxFileSize; dto.multipartMaxRequestSize = config.multipartMaxRequestSize; } return dto; } }
private void mapServlet(WhiteboardServlet whiteBoardServlet, List<ServletDTO> servletDTOs, List<FailedServletDTO> failedServletDTOs) { ServletDTO dto = new ServletDTO(); ServletMapping servletMapping = whiteBoardServlet.getServletMapping(); dto.serviceId = whiteBoardServlet.getServiceID(); dto.name = servletMapping.getServletName(); dto.initParams = servletMapping.getInitParams(); dto.patterns = servletMapping.getUrlPatterns(); dto.servletInfo = servletMapping.getServlet().getServletInfo(); dto.asyncSupported = servletMapping.getAsyncSupported() != null ? servletMapping.getAsyncSupported() : false; Optional<Map.Entry<ServiceReference<ServletContext>, ServletContext>> matchingServletContextEntry = findMatchingServletContext( servletMapping.getHttpContextId()); if (matchingServletContextEntry.isPresent()) { dto.servletContextId = (long) matchingServletContextEntry.get().getKey().getProperty(Constants.SERVICE_ID); } if (!whiteBoardServlet.isValid()) { failedServletDTOs.add( transformToFailedDTO( dto, FailedServletDTO.class, DTOConstants.FAILURE_REASON_VALIDATION_FAILED)); } else if (!matchingServletContextEntry.isPresent()) { failedServletDTOs.add( transformToFailedDTO( dto, FailedServletDTO.class, DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING)); } else { servletDTOs.add(dto); } }