/*
 *  (c) 2012 University of Bolton
 *  
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 * limitations under the License.
 */
package uk.ac.edukapp.servlets;

import java.io.IOException;
import java.io.OutputStream;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import uk.ac.edukapp.model.Widgetprofile;
import uk.ac.edukapp.renderer.MetadataRenderer;
import uk.ac.edukapp.service.WidgetProfileService;

/**
 * Featured Widgets API endpoint
 * @author scottw
 *
 */
public class FeaturedServlet  extends HttpServlet{
	
	/* (non-Javadoc)
	 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		WidgetProfileService widgetProfileService = new WidgetProfileService(req.getServletContext());
		List<Widgetprofile> widgetProfiles = widgetProfileService.findFeaturedWidgetProfiles();
		
		OutputStream out = resp.getOutputStream();
		MetadataRenderer.render(out, widgetProfiles);
		out.flush();
		out.close();
	}

}

@@ -692,16 +692,44 @@
 Stream;%0A
+import java.util.ArrayList;%0A
 import j
@@ -743,16 +743,16 @@
 l.List;%0A
-
 %0Aimport 
@@ -958,16 +958,69 @@
 rofile;%0A
+import uk.ac.edukapp.renderer.ExtendedWidgetProfile;%0A
 import u
@@ -1059,16 +1059,56 @@
 nderer;%0A
+import uk.ac.edukapp.renderer.Renderer;%0A
 import u
@@ -1732,16 +1732,520 @@
 s();%0A%09%09%0A
+%09%09//%0A%09%09// Get extended profile info%0A%09%09//%0A%09%09List%3CExtendedWidgetProfile%3E extendedWidgetProfiles = new ArrayList%3CExtendedWidgetProfile%3E();%0A%09%09for (Widgetprofile widgetProfile: widgetProfiles)%7B%0A%09%09%09ExtendedWidgetProfile extendedWidgetProfile = new ExtendedWidgetProfile();%0A%09%09%09extendedWidgetProfile.setWidgetProfile(widgetProfile);%0A%09%09%09%0A%09%09%09//%0A%09%09%09// Get instance rendering%0A%09%09%09//%0A%09%09%09extendedWidgetProfile.setRenderInfo(Renderer.render(widgetProfile));%0A%0A%09%09%09extendedWidgetProfiles.add(extendedWidgetProfile);%0A%09%09%7D%0A%09%09%0A
 %09%09Output
@@ -2312,17 +2312,25 @@
 er(out, 
-w
+extendedW
 idgetPro

Return extended profiles for Featured widgets include render info