Example usage for org.springframework.core.io Resource getURI

List of usage examples for org.springframework.core.io Resource getURI

Introduction

In this page you can find the example usage for org.springframework.core.io Resource getURI.

Prototype

URI getURI() throws IOException;

Source Link

Document

Return a URI handle for this resource.

Usage

From source file:org.trpr.platform.servicefw.impl.spring.web.ServiceController.java

/** Controller for deploy page (called from modify) */
@RequestMapping(value = { "/deploy/services/{serviceName}" }, method = RequestMethod.POST)
public String deploy(ModelMap model, @ModelAttribute("services") String serviceName,
        @RequestParam(defaultValue = "") String XMLFileContents) {
    model.addAttribute("serviceName", serviceName);

    try {//w  ww .j  a  va  2 s  .c o m
        this.configurationService.modifyConfig(this.constructServiceKey(serviceName),
                new ByteArrayResource(XMLFileContents.getBytes()));
    } catch (Exception e) {
        model.addAttribute("XMLFileError", "Unable to deploy file");
        StringWriter errors = new StringWriter();
        e.printStackTrace(new PrintWriter(errors));
        model.addAttribute("LoadingError", errors.toString());
        if (errors.toString() == null) {
            model.addAttribute("LoadingError", "Unexpected error");
        }
        model.addAttribute("XMLFileContents",
                getContents(this.configurationService.getConfig(this.constructServiceKey(serviceName))));
        return "modifyConfig";
    }
    //Loading success
    model.addAttribute("SuccessMessage", "Successfully Deployed the new Handler Configuration");
    Resource handlerFile = this.configurationService.getConfig(this.constructServiceKey(serviceName));
    model.addAttribute("XMLFileContents", getContents(handlerFile));
    try {
        model.addAttribute("XMLFileName", handlerFile.getURI());
    } catch (IOException e) {
        model.addAttribute("XMLFileName", "File not found");
    }
    return "viewConfig";
}