test_class.declarator: SITEMAP_NAME = "testSitemap"
test_class.modifier: private static final
test_class.original_string: private static final String SITEMAP_NAME = "testSitemap";
test_class.type: String
test_class.var_name: SITEMAP_NAME
test_class.declarator: SWITCH_WIDGET_ID = "switchWidget"
test_class.modifier: private static final
test_class.original_string: private static final String SWITCH_WIDGET_ID = "switchWidget";
test_class.type: String
test_class.var_name: SWITCH_WIDGET_ID
test_class.declarator: IMAGE_WIDGET_ID = "imageWidget"
test_class.modifier: private static final
test_class.original_string: private static final String IMAGE_WIDGET_ID = "imageWidget";
test_class.type: String
test_class.var_name: IMAGE_WIDGET_ID
test_class.declarator: VIDEO_WIDGET_ID = "videoWidget"
test_class.modifier: private static final
test_class.original_string: private static final String VIDEO_WIDGET_ID = "videoWidget";
test_class.type: String
test_class.var_name: VIDEO_WIDGET_ID
test_class.declarator: ITEM_NAME_UNDEF_STATE = "itemUNDEF"
test_class.modifier: private static final
test_class.original_string: private static final String ITEM_NAME_UNDEF_STATE = "itemUNDEF";
test_class.type: String
test_class.var_name: ITEM_NAME_UNDEF_STATE
test_class.declarator: ITEM_NAME_NULL_STATE = "itemNULL"
test_class.modifier: private static final
test_class.original_string: private static final String ITEM_NAME_NULL_STATE = "itemNULL";
test_class.type: String
test_class.var_name: ITEM_NAME_NULL_STATE
test_class.declarator: ITEM_NAME_ON_STATE = "itemON"
test_class.modifier: private static final
test_class.original_string: private static final String ITEM_NAME_ON_STATE = "itemON";
test_class.type: String
test_class.var_name: ITEM_NAME_ON_STATE
test_class.declarator: ITEM_NAME_INVALID_URL = "itemInvalidUrl"
test_class.modifier: private static final
test_class.original_string: private static final String ITEM_NAME_INVALID_URL = "itemInvalidUrl";
test_class.type: String
test_class.var_name: ITEM_NAME_INVALID_URL
test_class.declarator: ITEM_NAME_VALID_IMAGE_URL = "itemValidImageUrl"
test_class.modifier: private static final
test_class.original_string: private static final String ITEM_NAME_VALID_IMAGE_URL = "itemValidImageUrl";
test_class.type: String
test_class.var_name: ITEM_NAME_VALID_IMAGE_URL
test_class.declarator: ITEM_NAME_VALID_VIDEO_URL = "itemValidVideoUrl"
test_class.modifier: private static final
test_class.original_string: private static final String ITEM_NAME_VALID_VIDEO_URL = "itemValidVideoUrl";
test_class.type: String
test_class.var_name: ITEM_NAME_VALID_VIDEO_URL
test_class.declarator: INVALID_URL = "test"
test_class.modifier: private static final
test_class.original_string: private static final String INVALID_URL = "test";
test_class.type: String
test_class.var_name: INVALID_URL
test_class.declarator: ITEM_VALID_IMAGE_URL = "https://openhab.org/item.jpg"
test_class.modifier: private static final
test_class.original_string: private static final String ITEM_VALID_IMAGE_URL = "https://openhab.org/item.jpg";
test_class.type: String
test_class.var_name: ITEM_VALID_IMAGE_URL
test_class.declarator: ITEM_VALID_VIDEO_URL = "https://openhab.org/item.mp4"
test_class.modifier: private static final
test_class.original_string: private static final String ITEM_VALID_VIDEO_URL = "https://openhab.org/item.mp4";
test_class.type: String
test_class.var_name: ITEM_VALID_VIDEO_URL
test_class.declarator: VALID_IMAGE_URL = "https://openhab.org/test.jpg"
test_class.modifier: private static final
test_class.original_string: private static final String VALID_IMAGE_URL = "https://openhab.org/test.jpg";
test_class.type: String
test_class.var_name: VALID_IMAGE_URL
test_class.declarator: VALID_VIDEO_URL = "https://openhab.org/test.mp4"
test_class.modifier: private static final
test_class.original_string: private static final String VALID_VIDEO_URL = "https://openhab.org/test.mp4";
test_class.type: String
test_class.var_name: VALID_VIDEO_URL
test_class.declarator: service
test_class.modifier: private static
test_class.original_string: private static ProxyServletService service;
test_class.type: ProxyServletService
test_class.var_name: service
test_class.declarator: itemUIRegistry
test_class.modifier: private
test_class.original_string: private ItemUIRegistry itemUIRegistry;
test_class.type: ItemUIRegistry
test_class.var_name: itemUIRegistry
test_class.declarator: modelRepository
test_class.modifier: private
test_class.original_string: private ModelRepository modelRepository;
test_class.type: ModelRepository
test_class.var_name: modelRepository
test_class.declarator: sitemap
test_class.modifier: private
test_class.original_string: private Sitemap sitemap;
test_class.type: Sitemap
test_class.var_name: sitemap
test_class.declarator: request
test_class.modifier: private
test_class.original_string: private HttpServletRequest request;
test_class.type: HttpServletRequest
test_class.var_name: request
test_class.declarator: switchWidget
test_class.modifier: private
test_class.original_string: private Switch switchWidget;
test_class.type: Switch
test_class.var_name: switchWidget
test_class.declarator: imageWidget
test_class.modifier: private
test_class.original_string: private Image imageWidget;
test_class.type: Image
test_class.var_name: imageWidget
test_class.declarator: videoWidget
test_class.modifier: private
test_class.original_string: private Video videoWidget;
test_class.type: Video
test_class.var_name: videoWidget
test_class.file: bundles/org.openhab.core.ui/src/test/java/org/openhab/core/ui/internal/proxy/ProxyServletServiceTest.java
test_class.identifier: ProxyServletServiceTest
test_case.body: @Test
      public void testProxyUriImageWithItemButUndefState() {
          when(request.getParameter(eq("widgetId"))).thenReturn(IMAGE_WIDGET_ID);
          when(imageWidget.getUrl()).thenReturn(VALID_IMAGE_URL);
          when(imageWidget.getItem()).thenReturn(ITEM_NAME_UNDEF_STATE);
          URI uri = service.uriFromRequest(request);
          assertNotNull(uri);
          assertEquals(uri.toString(), VALID_IMAGE_URL);
      }
test_case.class_method_signature: ProxyServletServiceTest.testProxyUriImageWithItemButUndefState()
test_case.full_signature: @Test public void testProxyUriImageWithItemButUndefState()
test_case.identifier: testProxyUriImageWithItemButUndefState
test_case.invocations: thenReturn when getParameter eq thenReturn when getUrl thenReturn when getItem uriFromRequest assertNotNull assertEquals toString
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testProxyUriImageWithItemButUndefState()
focal_class.declarator: PROXY_ALIAS = "proxy"
focal_class.modifier: public static final
focal_class.original_string: public static final String PROXY_ALIAS = "proxy";
focal_class.type: String
focal_class.var_name: PROXY_ALIAS
focal_class.declarator: CONFIG_MAX_THREADS = "maxThreads"
focal_class.modifier: private static final
focal_class.original_string: private static final String CONFIG_MAX_THREADS = "maxThreads";
focal_class.type: String
focal_class.var_name: CONFIG_MAX_THREADS
focal_class.declarator: DEFAULT_MAX_THREADS = 8
focal_class.modifier: private static final
focal_class.original_string: private static final int DEFAULT_MAX_THREADS = 8;
focal_class.type: int
focal_class.var_name: DEFAULT_MAX_THREADS
focal_class.declarator: ATTR_URI = ProxyServletService.class.getName() + ".URI"
focal_class.modifier: public static final
focal_class.original_string: public static final String ATTR_URI = ProxyServletService.class.getName() + ".URI";
focal_class.type: String
focal_class.var_name: ATTR_URI
focal_class.declarator: ATTR_SERVLET_EXCEPTION = ProxyServletService.class.getName() + ".ProxyServletException"
focal_class.modifier: public static final
focal_class.original_string: public static final String ATTR_SERVLET_EXCEPTION = ProxyServletService.class.getName() + ".ProxyServletException";
focal_class.type: String
focal_class.var_name: ATTR_SERVLET_EXCEPTION
focal_class.declarator: logger = LoggerFactory.getLogger(ProxyServletService.class)
focal_class.modifier: private final
focal_class.original_string: private final Logger logger = LoggerFactory.getLogger(ProxyServletService.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: serialVersionUID = -4716754591953017793L
focal_class.modifier: private static final
focal_class.original_string: private static final long serialVersionUID = -4716754591953017793L;
focal_class.type: long
focal_class.var_name: serialVersionUID
focal_class.declarator: impl
focal_class.modifier: private
focal_class.original_string: private Servlet impl;
focal_class.type: Servlet
focal_class.var_name: impl
focal_class.declarator: httpService
focal_class.modifier: protected
focal_class.original_string: protected HttpService httpService;
focal_class.type: HttpService
focal_class.var_name: httpService
focal_class.declarator: itemUIRegistry
focal_class.modifier: protected
focal_class.original_string: protected ItemUIRegistry itemUIRegistry;
focal_class.type: ItemUIRegistry
focal_class.var_name: itemUIRegistry
focal_class.declarator: modelRepository
focal_class.modifier: protected
focal_class.original_string: protected ModelRepository modelRepository;
focal_class.type: ModelRepository
focal_class.var_name: modelRepository
focal_class.file: bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/proxy/ProxyServletService.java
focal_class.identifier: ProxyServletService
focal_class.class_method_signature: ProxyServletService.setItemUIRegistry(ItemUIRegistry itemUIRegistry)
focal_class.full_signature: @Reference(policy = ReferencePolicy.DYNAMIC) protected void setItemUIRegistry(ItemUIRegistry itemUIRegistry)
focal_class.identifier: setItemUIRegistry
focal_class.modifiers: @Reference(policy = ReferencePolicy.DYNAMIC) protected
focal_class.parameters: (ItemUIRegistry itemUIRegistry)
focal_class.return: void
focal_class.signature: void setItemUIRegistry(ItemUIRegistry itemUIRegistry)
focal_class.class_method_signature: ProxyServletService.unsetItemUIRegistry(ItemUIRegistry itemUIRegistry)
focal_class.full_signature: protected void unsetItemUIRegistry(ItemUIRegistry itemUIRegistry)
focal_class.identifier: unsetItemUIRegistry
focal_class.modifiers: protected
focal_class.parameters: (ItemUIRegistry itemUIRegistry)
focal_class.return: void
focal_class.signature: void unsetItemUIRegistry(ItemUIRegistry itemUIRegistry)
focal_class.class_method_signature: ProxyServletService.setModelRepository(ModelRepository modelRepository)
focal_class.full_signature: @Reference protected void setModelRepository(ModelRepository modelRepository)
focal_class.identifier: setModelRepository
focal_class.modifiers: @Reference protected
focal_class.parameters: (ModelRepository modelRepository)
focal_class.return: void
focal_class.signature: void setModelRepository(ModelRepository modelRepository)
focal_class.class_method_signature: ProxyServletService.unsetModelRepository(ModelRepository modelRepository)
focal_class.full_signature: protected void unsetModelRepository(ModelRepository modelRepository)
focal_class.identifier: unsetModelRepository
focal_class.modifiers: protected
focal_class.parameters: (ModelRepository modelRepository)
focal_class.return: void
focal_class.signature: void unsetModelRepository(ModelRepository modelRepository)
focal_class.class_method_signature: ProxyServletService.setHttpService(HttpService httpService)
focal_class.full_signature: @Reference(policy = ReferencePolicy.DYNAMIC) protected void setHttpService(HttpService httpService)
focal_class.identifier: setHttpService
focal_class.modifiers: @Reference(policy = ReferencePolicy.DYNAMIC) protected
focal_class.parameters: (HttpService httpService)
focal_class.return: void
focal_class.signature: void setHttpService(HttpService httpService)
focal_class.class_method_signature: ProxyServletService.unsetHttpService(HttpService httpService)
focal_class.full_signature: protected void unsetHttpService(HttpService httpService)
focal_class.identifier: unsetHttpService
focal_class.modifiers: protected
focal_class.parameters: (HttpService httpService)
focal_class.return: void
focal_class.signature: void unsetHttpService(HttpService httpService)
focal_class.class_method_signature: ProxyServletService.getImpl()
focal_class.full_signature: private Servlet getImpl()
focal_class.identifier: getImpl
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: Servlet
focal_class.signature: Servlet getImpl()
focal_class.class_method_signature: ProxyServletService.propsFromConfig(Map<String, Object> config)
focal_class.full_signature: private Hashtable<String, String> propsFromConfig(Map<String, Object> config)
focal_class.identifier: propsFromConfig
focal_class.modifiers: private
focal_class.parameters: (Map<String, Object> config)
focal_class.return: Hashtable<String, String>
focal_class.signature: Hashtable<String, String> propsFromConfig(Map<String, Object> config)
focal_class.class_method_signature: ProxyServletService.activate(Map<String, Object> config)
focal_class.full_signature: @Activate protected void activate(Map<String, Object> config)
focal_class.identifier: activate
focal_class.modifiers: @Activate protected
focal_class.parameters: (Map<String, Object> config)
focal_class.return: void
focal_class.signature: void activate(Map<String, Object> config)
focal_class.class_method_signature: ProxyServletService.deactivate()
focal_class.full_signature: @Deactivate protected void deactivate()
focal_class.identifier: deactivate
focal_class.modifiers: @Deactivate protected
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void deactivate()
focal_class.class_method_signature: ProxyServletService.createHttpContext()
focal_class.full_signature: protected HttpContext createHttpContext()
focal_class.identifier: createHttpContext
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: HttpContext
focal_class.signature: HttpContext createHttpContext()
focal_class.class_method_signature: ProxyServletService.uriFromRequest(HttpServletRequest request)
focal_class.full_signature:  URI uriFromRequest(HttpServletRequest request)
focal_class.identifier: uriFromRequest
focal_class.parameters: (HttpServletRequest request)
focal_class.return: URI
focal_class.signature: URI uriFromRequest(HttpServletRequest request)
focal_class.class_method_signature: ProxyServletService.createURIFromString(String url)
focal_class.full_signature: private URI createURIFromString(String url)
focal_class.identifier: createURIFromString
focal_class.modifiers: private
focal_class.parameters: (String url)
focal_class.return: URI
focal_class.signature: URI createURIFromString(String url)
focal_class.class_method_signature: ProxyServletService.maybeAppendAuthHeader(URI uri, Request request)
focal_class.full_signature:  void maybeAppendAuthHeader(URI uri, Request request)
focal_class.identifier: maybeAppendAuthHeader
focal_class.parameters: (URI uri, Request request)
focal_class.return: void
focal_class.signature: void maybeAppendAuthHeader(URI uri, Request request)
focal_class.class_method_signature: ProxyServletService.proxyingVideoWidget(HttpServletRequest request)
focal_class.full_signature:  boolean proxyingVideoWidget(HttpServletRequest request)
focal_class.identifier: proxyingVideoWidget
focal_class.parameters: (HttpServletRequest request)
focal_class.return: boolean
focal_class.signature: boolean proxyingVideoWidget(HttpServletRequest request)
focal_class.class_method_signature: ProxyServletService.sendError(HttpServletRequest request, HttpServletResponse response)
focal_class.full_signature:  void sendError(HttpServletRequest request, HttpServletResponse response)
focal_class.identifier: sendError
focal_class.parameters: (HttpServletRequest request, HttpServletResponse response)
focal_class.return: void
focal_class.signature: void sendError(HttpServletRequest request, HttpServletResponse response)
focal_class.superclass: extends HttpServlet
focal_method.body: URI uriFromRequest(HttpServletRequest request) {
          try {
              // Return any URI we've already saved for this request
              URI uri = (URI) request.getAttribute(ATTR_URI);
              if (uri != null) {
                  return uri;
              } else {
                  ProxyServletException pse = (ProxyServletException) request.getAttribute(ATTR_SERVLET_EXCEPTION);
                  if (pse != null) {
                      // If we errored on this request before, there is no point continuing
                      return null;
                  }
              }
  
              String sitemapName = request.getParameter("sitemap");
              if (sitemapName == null) {
                  throw new ProxyServletException(HttpServletResponse.SC_BAD_REQUEST,
                          "Parameter 'sitemap' must be provided!");
              }
  
              String widgetId = request.getParameter("widgetId");
              if (widgetId == null) {
                  throw new ProxyServletException(HttpServletResponse.SC_BAD_REQUEST,
                          "Parameter 'widgetId' must be provided!");
              }
  
              Sitemap sitemap = (Sitemap) modelRepository.getModel(sitemapName);
              if (sitemap == null) {
                  throw new ProxyServletException(HttpServletResponse.SC_NOT_FOUND,
                          String.format("Sitemap '%s' could not be found!", sitemapName));
              }
  
              Widget widget = itemUIRegistry.getWidget(sitemap, widgetId);
              if (widget == null) {
                  throw new ProxyServletException(HttpServletResponse.SC_NOT_FOUND,
                          String.format("Widget '%s' could not be found!", widgetId));
              }
  
              String uriString = null;
              if (widget instanceof Image) {
                  uriString = ((Image) widget).getUrl();
              } else if (widget instanceof Video) {
                  uriString = ((Video) widget).getUrl();
              } else {
                  throw new ProxyServletException(HttpServletResponse.SC_FORBIDDEN,
                          String.format("Widget type '%s' is not supported!", widget.getClass().getName()));
              }
  
              String itemName = widget.getItem();
              if (itemName != null) {
                  State state = itemUIRegistry.getItemState(itemName);
                  if (state != null && state instanceof StringType) {
                      try {
                          uri = createURIFromString(state.toString());
                          request.setAttribute(ATTR_URI, uri);
                          return uri;
                      } catch (MalformedURLException | URISyntaxException ex) {
                          // fall thru
                      }
                  }
              }
  
              try {
                  uri = createURIFromString(uriString);
                  request.setAttribute(ATTR_URI, uri);
                  return uri;
              } catch (MalformedURLException | URISyntaxException ex) {
                  throw new ProxyServletException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                          String.format("URL '%s' is not a valid URL.", uriString));
              }
          } catch (ProxyServletException pse) {
              request.setAttribute(ATTR_SERVLET_EXCEPTION, pse);
              return null;
          }
      }
focal_method.class_method_signature: ProxyServletService.uriFromRequest(HttpServletRequest request)
focal_method.full_signature:  URI uriFromRequest(HttpServletRequest request)
focal_method.identifier: uriFromRequest
focal_method.invocations: getAttribute getAttribute getParameter getParameter getModel format getWidget format getUrl getUrl format getName getClass getItem getItemState createURIFromString toString setAttribute createURIFromString setAttribute format setAttribute
focal_method.parameters: (HttpServletRequest request)
focal_method.return: URI
focal_method.signature: URI uriFromRequest(HttpServletRequest request)