package uk.ac.edukapp.renderer;

import org.apache.wookie.connector.framework.WookieConnectorException;
import org.apache.wookie.connector.framework.WookieConnectorService;



public class WidgetRenderer {
	public static String render(String url){
		
		try {
			WookieConnectorService conn = new WookieConnectorService("http://widgets.open.ac.uk:8080/wookie/", "TEST", "myshareddata");
		} catch (WookieConnectorException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		
		return null;
	}
}

@@ -39,261 +39,542 @@
 ort 
-org.apache.wookie.connector.framework.WookieConnectorException;%0D%0Aimport org.apache.wookie.connector.framework.WookieConnectorService;%0D%0A%0D%0A%0D%0A%0D%0Apublic class WidgetRenderer %7B%0D%0A%09public static String render(String url)%7B%0D%0A%09%09%0D%0A%09%09try %7B%0D%0A%09%09%09WookieConnectorService
+java.io.IOException;%0D%0A%0D%0Aimport org.apache.wookie.connector.framework.User;%0D%0Aimport org.apache.wookie.connector.framework.WidgetInstance;%0D%0Aimport org.apache.wookie.connector.framework.WookieConnectorException;%0D%0Aimport org.apache.wookie.connector.framework.WookieConnectorService;%0D%0A%0D%0Aimport uk.ac.edukapp.repository.SolrConnector;%0D%0A%0D%0A%0D%0A%0D%0Apublic class WidgetRenderer %7B%0D%0A  %0D%0A  private static WidgetRenderer renderer = new WidgetRenderer();%0D%0A  %0D%0A  private WookieConnectorService conn;%0D%0A  %0D%0A  %0D%0A  private WidgetRenderer()%7B%0D%0A    try %7B%0D%0A     
  con
@@ -674,20 +674,26 @@
 a%22);
-%0D%0A%09%09%7D 
+      %0D%0A    %7D
 catch
- 
 (Woo
@@ -718,101 +718,926 @@
 ion 
-e) %7B%0D%0A%09%09%09// TODO Auto-generated catch block%0D%0A%09%09%09e.printStackTrace();%0D%0A%09%09%7D%0D%0A%0D%0A%09%09%0D%0A%09%09
+wce)%7B%0D%0A      wce.printStackTrace();%0D%0A    %7D%0D%0A  %7D  %0D%0A  %0D%0A  %0D%0A  public static WidgetRenderer getInstance() %7B%0D%0A    return renderer;%0D%0A  %7D%0D%0A  %0D%0A  /**%0D%0A   * Returns html markup of widget instance as an iframe%0D%0A   * @param the id (typically a uri) of widget to render%0D%0A   * @return html-ready code as a string%0D%0A   */%0D%0A%09public String render(String uri)%7B%0D%0A%09  String html = %22%22;%0D%0A%09  WidgetInstance widgetInstance = null;%0D%0A%09  try %7B%0D%0A%09    conn.setCurrentUser(new User(%22edukapp-front-page%22,%22edukapp-front-page%22));%0D%0A%09    widgetInstance = conn.getOrCreateInstance(uri);%0D%0A%09  %7Dcatch(IOException ioe)%7B%0D%0A%09    ioe.printStackTrace();%0D%0A%09    return null;%0D%0A%09  %7Dcatch(WookieConnectorException wce)%7B%0D%0A%09    wce.printStackTrace();%0D%0A%09    return null;%0D%0A%09  %7D%0D%0A%09  html+=%22%3Cp%3E%22+uri+%22%3C/p%3E%22;%0D%0A%09  html+=%22%3Ciframe src=%5C%22%22+widgetInstance.getUrl()+%22%5C%22%22;%0D%0A%09  html+=%22 width=%5C%22%22+%22100%22+%22%5C%22%22;%0D%0A%09  html+=%22 height=%5C%22%22+%22100%22+%22%5C%22%22;%0D%0A%09  html+=%22%3E%3C/iframe%3E%22;%0D%0A%09  
 return 
-nul
+htm
 l;%0D%0A

set up widget renderer as a Singleton