/*
 *  Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. licenses this file to you 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 org.wso2.carbon.dashboards.api;

import org.osgi.service.component.annotations.Component;
import org.wso2.carbon.dashboards.core.widget.info.WidgetInfoProviderImpl;
import org.wso2.msf4j.Microservice;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;


/**
 * This is the back-end api to get the widget related information.
 */
@Component(
        name = "org.wso2.carbon.dashboards.api.WidgetInfoProviderAPI",
        service = Microservice.class,
        immediate = true
)
@Path("/apis/widgets")
public class WidgetApi implements Microservice {

    /**
     * This method returns a list of meta information of widgets.
     *
     * @return List of widget related meta information
     */
    @GET
    @Path("/")
    @Produces(MediaType.APPLICATION_JSON)
    public Response getWidgetsMetaInfo() {
        WidgetInfoProviderImpl widgetInfoProvider = new WidgetInfoProviderImpl();
        return Response.ok().entity(widgetInfoProvider.getWidgetsMetaInfo()).build();
    }

    /**
     * This method return the configuration of given widget.
     *
     * @param widgetId widget id
     * @return widget configuration
     */
    @GET
    @Path("/{id}/conf")
    @Produces(MediaType.APPLICATION_JSON)
    public Response getWidgetConf(@PathParam("id") String widgetId) {
        return Response.ok().build();
    }

    /**
     * This method provides thumbnail of given widget.
     *
     * @param widgetId widget id
     * @return thumbnail of given widget
     */
    @GET
    @Path("/{id}/thumbnail")
    public Response getThumbnail(@PathParam("id") String widgetId) {
        return Response.ok().build();
    }
}

@@ -1,14 +1,13 @@
 /*%0A *
- 
  Copyrig
@@ -77,17 +77,16 @@
 d.%0A *%0A *
- 
  WSO2 In
@@ -142,17 +142,16 @@
 ense,%0A *
- 
  Version
@@ -207,17 +207,16 @@
 xcept%0A *
- 
  in comp
@@ -242,17 +242,16 @@
 ense.%0A *
- 
  You may
@@ -288,16 +288,17 @@
 at%0A *%0A *
+ 
   http:/
@@ -339,17 +339,16 @@
 .0%0A *%0A *
- 
  Unless 
@@ -401,17 +401,16 @@
 ting,%0A *
- 
  softwar
@@ -464,17 +464,16 @@
 on an%0A *
- 
  %22AS IS%22
@@ -522,17 +522,16 @@
 F ANY%0A *
- 
  KIND, e
@@ -583,17 +583,16 @@
 r the%0A *
- 
  specifi
@@ -642,17 +642,16 @@
 tions%0A *
- 
  under t
@@ -666,15 +666,13 @@
 se.%0A
- *%0A
  */%0A
+%0A
 pack
@@ -728,47 +728,259 @@
 sgi.
-service.component.annotations.Component
+framework.BundleContext;%0Aimport org.osgi.service.component.annotations.Activate;%0Aimport org.osgi.service.component.annotations.Component;%0Aimport org.osgi.service.component.annotations.Deactivate;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory
 ;%0Aim
@@ -1271,51 +1271,27 @@
 e;%0A%0A
-%0A
 /**%0A * 
-This is the back-end api to get the
+REST API for
  wid
@@ -1306,21 +1306,39 @@
 ted 
-inform
+oper
 ation
+s
 .%0A
+ *%0A * @since 4.0.0%0A
  */%0A
@@ -1348,25 +1348,16 @@
 mponent(
-%0A        
 name = %22
@@ -1397,23 +1397,11 @@
 dget
-InfoProviderAPI
+Api
 %22,%0A 
@@ -1407,16 +1407,19 @@
         
+   
 service 
@@ -1440,16 +1440,19 @@
 .class,%0A
+   
         
@@ -1543,16 +1543,398 @@
 vice %7B%0A%0A
+    private static final Logger LOGGER = LoggerFactory.getLogger(WidgetApi.class);%0A%0A    @Activate%0A    protected void activate(BundleContext bundleContext) %7B%0A        LOGGER.debug(%22%7B%7D activated.%22, this.getClass().getName());%0A    %7D%0A%0A    @Deactivate%0A    protected void deactivate(BundleContext bundleContext) %7B%0A        LOGGER.debug(%22%7B%7D deactivated.%22, this.getClass().getName());%0A    %7D%0A%0A
     /**%0A
@@ -2643,32 +2643,67 @@
 ing widgetId) %7B%0A
+        // TODO: 11/8/17 Implement%0A
         return R
@@ -2982,32 +2982,67 @@
 ing widgetId) %7B%0A
+        // TODO: 11/8/17 Implement%0A
         return R

refactor WidgetApi class