All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.formkiq.server.controller.admin.AdminController Maven / Gradle / Ivy
/*
* Copyright (C) 2016 FormKiQ Inc.
*
* 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 com.formkiq.server.controller.admin;
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.FolderService;
/**
* Admin Controller.
*
*/
@Controller
@RequestMapping(value = "/admin")
public class AdminController {
/** FolderService. */
@Autowired
private FolderService folderservice;
/**
* Admin Clients page.
* @return {@link String}
*/
@RequestMapping(value = "/clients", method = RequestMethod.GET)
public String clients() {
return "admin/clients";
}
/**
* Download Form.
* @param request {@link HttpServletRequest}
* @param response {@link HttpServletResponse}
* @param folder {@link String}
* @param uuid {@link String}
* @throws IOException IOException
*/
@Transactional
@RequestMapping("/download")
public void download(
final HttpServletRequest request,
final HttpServletResponse response,
@RequestParam(value = "folder", required = true)
final String folder,
@RequestParam(value = "uuid", required = true) final String uuid)
throws IOException {
byte[] data = this.folderservice.findFormData(folder, uuid);
response.setContentType("application/zip");
response.setHeader("Content-disposition",
"attachment; filename=" + uuid + ".zip");
response.setContentLengthLong(data.length);
IOUtils.write(data, response.getOutputStream());
}
/**
* Admin Folders page.
* @return {@link String}
*/
@RequestMapping(value = "/folders", method = RequestMethod.GET)
public String folders() {
return "admin/folders";
}
/**
* 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";
}
/**
* Admin Index.
* @return {@link String}
*/
@RequestMapping(value = "/index", method = RequestMethod.GET)
public String index() {
return "redirect:/admin/users";
}
/**
* Admin System Properties page.
* @return {@link String}
*/
@RequestMapping(value = "/systemproperties", method = RequestMethod.GET)
public String systemproperties() {
return "admin/systemproperties";
}
/**
* Admin Edit System Properties page.
* @return {@link String}
*/
@RequestMapping(value = "/systemproperties/edit",
method = RequestMethod.GET)
public String systempropertiesEdit() {
return "admin/systemproperties/edit";
}
/**
* Admin Delete System Properties page.
* @return {@link String}
*/
@RequestMapping(value = "/systemproperties/delete",
method = RequestMethod.GET)
public String systempropertiesDelete() {
return "admin/systemproperties/delete";
}
/**
* Admin Users page.
* @return {@link String}
*/
@RequestMapping(value = "/users", method = RequestMethod.GET)
public String users() {
return "admin/users";
}
/**
* Admin Delete Users page.
* @return {@link String}
*/
@RequestMapping(value = "/users/delete", method = RequestMethod.GET)
public String usersDelete() {
return "admin/users/delete";
}
/**
* Admin Edit Users page.
* @return {@link String}
*/
@RequestMapping(value = "/users/edit", method = RequestMethod.GET)
public String usersedit() {
return "admin/users/edit";
}
/**
* Admin Reset Password Users page.
* @return {@link String}
*/
@RequestMapping(value = "/users/resetpassword", method = RequestMethod.GET)
public String usersResetPassword() {
return "admin/users/resetpassword";
}
/**
* Admin Workflows page.
* @return {@link String}
*/
@RequestMapping(value = "/workflows", method = RequestMethod.GET)
public String workflows() {
return "admin/workflows";
}
}