![JAR search and dependency download from the Maven repository](/logo.png)
com.formkiq.server.controller.AdminController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of greeting Show documentation
Show all versions of greeting Show documentation
Server-side integration for the FormKiQ ios application
The newest version!
package com.formkiq.server.controller;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.transaction.Transactional;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.formkiq.server.service.FormService;
/**
* Admin Controller.
*
*/
@Controller
@RequestMapping(value = "/admin")
public class AdminController {
/** FormService. */
@Autowired
private FormService formservice;
/**
* Admin Clients page.
* @return {@link String}
*/
@RequestMapping(value = "/clients", method = RequestMethod.GET)
public String clients() {
return "admin/clients";
}
/**
* Admin Forms page.
* @param type {@link String}
* @param client {@link String}
* @param name {@link String}
* @param uuid {@link String}
* @return {@link String}
*/
@RequestMapping(value = "/forms", method = RequestMethod.GET)
public String forms(
@RequestParam(value = "type", required = false)
final String type,
@RequestParam(value = "client", required = false)
final String client,
@RequestParam(value = "name", required = false)
final String name,
@RequestParam(value = "uuid", required = false)
final String uuid) {
if (StringUtils.isEmpty(type)) {
return "redirect:/admin/index";
}
if (!StringUtils.isEmpty(name) && !StringUtils.isEmpty(uuid)
&& !StringUtils.isEmpty(client)) {
return "admin/formdetails";
}
return "admin/forms";
}
/**
* Download Form.
* @param request {@link HttpServletRequest}
* @param response {@link HttpServletResponse}
* @param client {@link String}
* @param uuid {@link String}
* @throws IOException IOException
*/
@Transactional
@RequestMapping("/download")
public void download(
final HttpServletRequest request,
final HttpServletResponse response,
@RequestParam(value = "client", required = true)
final String client,
@RequestParam(value = "uuid", required = true) final String uuid)
throws IOException {
// TODO zip workflow with all forms
byte[] data = this.formservice.findFormData(client, uuid);
response.setContentType("application/zip");
response.setHeader("Content-disposition",
"attachment; filename=" + uuid + ".zip");
response.setContentLengthLong(data.length);
IOUtils.write(data, response.getOutputStream());
}
/**
* Admin Index.
* @return {@link String}
*/
@RequestMapping(value = "/index", method = RequestMethod.GET)
public String index() {
return "redirect:/admin/users";
}
/**
* Admin Users page.
* @return {@link String}
*/
@RequestMapping(value = "/users", method = RequestMethod.GET)
public String users() {
return "admin/users";
}
/**
* Admin Workflows page.
* @return {@link String}
*/
@RequestMapping(value = "/workflows", method = RequestMethod.GET)
public String workflows() {
return "admin/workflows";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy