/**
 * Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U <br>
 * This file is part of FI-WARE project.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License.
 * </p>
 * <p>
 * You may obtain a copy of the License at:<br>
 * <br>
 * http://www.apache.org/licenses/LICENSE-2.0
 * </p>
 * <p>
 * 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.
 * </p>
 * <p>
 * See the License for the specific language governing permissions and limitations under the License.
 * </p>
 * <p>
 * For those usages not covered by the Apache version 2.0 License please contact with opensource@tid.es
 * </p>
 */

package com.telefonica.euro_iaas.sdc.puppetwrapper.controllers;

import java.io.IOException;
import java.util.NoSuchElementException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import com.telefonica.euro_iaas.sdc.puppetwrapper.common.Error;

public class GenericController {

    @ExceptionHandler(NoSuchElementException.class)
    public ModelAndView handleNoSuchElementException(NoSuchElementException ex, HttpServletResponse response) {
        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
        return handleModelAndView(ex.getMessage());
    }

    public ModelAndView handleModelAndView(String error) {
        ModelAndView model = new ModelAndView();
        model.addObject(error);
        return model;

    }
}

@@ -911,36 +911,8 @@
 s;%0A%0A
-import java.io.IOException;%0A
 impo
@@ -948,16 +948,16 @@
 eption;%0A
+
 %0Aimport 
@@ -1170,20 +1170,38 @@
 per.
-common.Error
+data.ModuleDownloaderException
 ;%0A%0Ap
@@ -1393,24 +1393,24 @@
 response) %7B%0A
-
         resp
@@ -1516,16 +1516,316 @@
 );%0A    %7D
+%0A    %0A    @ExceptionHandler(ModuleDownloaderException.class)%0A    public ModelAndView handleModuleDownloaderException(ModuleDownloaderException ex, HttpServletResponse response) %7B%0A        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);%0A        return handleModelAndView(ex.getMessage());%0A    %7D
 %0A%0A    pu

add exception handler for the download error