Системы электронного документооборота
Разработка универсальной системы электронного документооборота HotDoc с разграничением прав доступа пользователей, с эффективной системой поиска документа, с возможностью внедрения в различные организации. Реализация программы в виде веб-приложения.
Рубрика | Программирование, компьютеры и кибернетика |
Вид | дипломная работа |
Язык | русский |
Дата добавления | 24.09.2012 |
Размер файла | 5,5 M |
Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже
Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.
Кроме того, в системе реализована рассылка оповещений. При добавлении задания определенному пользователю, он получает оповещение об этом на почту.
Созданное приложение легко в освоении, удобно в использовании и оперативном получении информации.
Прототип системы документооборота, организованный по модульной архитектуре, может быть легко доработан до коммерческого предложения.
Данная работа помимо этого подразумевала учебную цель: ознакомление с Java Server-Side - технологиями. При разработке системы были использованы современные информационные технологии: JavaEE - JSP, Servlets, JSP, JDBC; технология AJAX. Цель была достигнута.
Система электронного документооборота HotDoc может иметь свое практическое применение, как в средних, так и в крупных организациях, где требуется ведение большого объема документов.
Список использованных источников и литературы
1. Дж. Боуман, С. Эмерсон, М. Дарновски Практическое руководство по SQL, 4-е изд.: Пер.с англ. - М.: Издательский дом "Вильямс", 2002
2. Философия Java. Библиотека программиста. 4-е изд. - СПб.: Питер, 2009
3. Java2. Библиотека профессионала, том 1. Основы, 7-е изд.: Пер. с англ. - М.: Издательский дом "Вильямс", 2007
4. Java2. Библиотека профессионала, том 2. Тонкости программирования, 7-е изд.: Пер. с англ. - М.: Издательский дом "Вильямс", 2007
5. http://www.bishelp.ru/uprbiz/avto/document.php
6. http://www.dvgu.ru/meteo/intra/ElectronDocument.htm
7. http://chtivo.webhost.ru/articles/mvc.php
8. http://www.webmascon.com/topics/development/22a.scenarios.asp
9. http://www.docflow.ru/analitics/detail.php?ID=19416
10. http://ru.wikipedia.org/wiki/AJAX
ПРИЛОЖЕНИЕ 1
Контроллер, отвечающий за аутентификацию
AuthServlet
package ru.ksu.eldoc.web;
import ru.ksu.eldoc.services.impl.UserGroupServiceImpl;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException;
import javax.servlet.RequestDispatcher;
import java.io.IOException;
public class AuthServlet extends HttpServlet {
protected String url;
protected String driver;
protected String user;
protected String password;
// actions
public static final String AUTH = "auth";
public static final String LOGIN_PAGE = "loginPage";
public static final String MESSAGE = "message";
public static final String LOGIN = "login";
public static final String PASSWORD = "password";
public static final String ADMIN = "admin";
public void init() throws ServletException {
super.init();
url = getInitParameter("url");
driver = getInitParameter("driver");
user = getInitParameter("user");
password = getInitParameter("password");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String action = request.getParameter("action");
if (action == null) action = LOGIN_PAGE;
String message = "";
try {
if (action.equals(LOGIN_PAGE)) {
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/loginPage.jsp");
requestDispatcher.include(request, response);
}
}
catch (Exception e) {
message = e.getMessage();
message = "loginPage error";
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/message.jsp");
requestDispatcher.include(request, response);
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String action = request.getParameter("action");
HttpSession session = request.getSession();
String message = "";
if (action != null) {
try {
UserGroupServiceImpl ugsi = new UserGroupServiceImpl(url, driver, user, password);
String checkLogin = request.getParameter(LOGIN);
String checkPassword = request.getParameter(PASSWORD);
boolean admin;
boolean ex = ugsi.authent(checkLogin, checkPassword);
if (ex) {
session.removeAttribute(LOGIN);
session.removeAttribute(PASSWORD);
session.removeAttribute(ADMIN);
session.setAttribute(LOGIN, checkLogin);
session.setAttribute(PASSWORD, checkPassword);
admin = false;
session.setAttribute(ADMIN, admin);
response.sendRedirect(request.getContextPath() + "/main");
} else {
ex = ugsi.adminAuthent(checkLogin, checkPassword);
if (ex) {
session.removeAttribute(LOGIN);
session.removeAttribute(PASSWORD);
session.removeAttribute(ADMIN);
session.setAttribute(LOGIN, checkLogin);
session.setAttribute(PASSWORD, checkPassword);
admin = true;
session.setAttribute(ADMIN, admin);
response.sendRedirect(request.getContextPath() + "/admin_main");
} else {
message = "wrong login or password!!";
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/message.jsp");
requestDispatcher.include(request, response);
}
}
}
catch (Exception e) {
message = e.getMessage() + "kjkj";
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/message.jsp");
requestDispatcher.include(request, response);
}
}
}
}
ПРИЛОЖЕНИЕ 2
Контроллер, отвечающий за работу администратора
AdminMainPageServlet
package ru.ksu.eldoc.web;
import ru.ksu.eldoc.objects.*;
import ru.ksu.eldoc.services.impl.FileFolderServiceImpl;
import ru.ksu.eldoc.services.impl.UserGroupServiceImpl;
import ru.ksu.eldoc.services.impl.TasksServiceImpl;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException;
import javax.servlet.RequestDispatcher;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.ArrayList;
import com.sun.jmx.snmp.tasks.Task;
public class AdminMainPageServlet extends HttpServlet {
protected String url;
protected String driver;
protected String user;
protected String password;
// actions
public static final String MAIN_PAGE = "mainPage";
// parameters
public static final String LOGIN = "login";
public static final String PASSWORD = "password";
public static final String MESSAGE = "message";
public static final String USURNAME = "uSurname";
public static final String UNAME = "uName";
public static final String PATRONYMIC = "patronymic";
public static final String JOB = "job";
public static final String FOLDERS = "folders";
public static final String NEW_DOCUMENT = "newDocument";
public static final String SHOW_TASKS = "showTasks";
public static final String TASKS = "my_Tasks";
public static final String NEW_TASK = "newTask";
public static final String TASK_ID = "taskId";
public static final String CREATE_NEW_TASK = "createNewTask";
public static final String TASK_TEXT = "taskText";
public static final String SHOW_FILE_ACCESS = "showFileAccess";
public static final String FILE_ACCESS = "fileAccess";
public static final String FOLDER_CONTENTS = "folderContents";
public static final String FOLDER_ID = "folderId";
public static final String FROM_FOLDER = "fromFolder";
public static final String FROM_FOLDER_ID = "fromFolderId";
public static final String DELETE_FOLDER = "deleteFolder";
public static final String DELETE_TASK = "deleteTask";
public static final String DELETE_FILE = "deleteFile";
public static final String FILE_ID = "fileId";
public static final String USERS = "users";
public static final String USER = "user";
public static final String USER_ID = "userId";
public static final String USER_LOGIN = "userLogin";
public static final String USERS_LIST = "usersList";
public static final String EDIT_USER = "editUser";
public static final String DELETE_USER = "deleteUser";
public static final String USER_EDIT = "userEdit";
public static final String USER_SURNAME = "userSurname";
public static final String USER_NAME = "userName";
public static final String USER_PATRONYMIC = "userPatronymic";
public static final String USER_JOB = "userJob";
public static final String USER_EMAIL = "userEmail";
public static final String USER_PASSWORD = "userPassword";
public static final String EXIT = "exit";
public static final String FILE_INFO = "fileInfo";
public static final String FILEINFO = "fileinfo";
public static final String FOLDER = "folder";
public static final String VERSION = "version";
public static final String VERSION_NUMBER = "versionNumber";
public void init() throws ServletException {
super.init();
url = getInitParameter("url");
driver = getInitParameter("driver");
user = getInitParameter("user");
password = getInitParameter("password");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String action = request.getParameter("action");
HttpSession session = request.getSession();
if (action == null) action = MAIN_PAGE;
String message = "";
try {
String login = (String) session.getAttribute(LOGIN);
String pass = (String) session.getAttribute(PASSWORD);
if (action != null) {
if (login == null)
response.sendRedirect(request.getContextPath() + "/auth");
else {
UserGroupServiceImpl ugsi = new UserGroupServiceImpl(url, driver, user, password);
FileFolderServiceImpl ffsi = new FileFolderServiceImpl(url, driver, user, password);
TasksServiceImpl tsi = new TasksServiceImpl(url, driver, user, password);
Admin a = new Admin(login, password);
request.setAttribute(USURNAME, a.getLogin());
if (action.equals(MAIN_PAGE)) {
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminMainPage.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(EXIT)) {
session.removeAttribute(LOGIN);
session.removeAttribute(PASSWORD);
response.sendRedirect(request.getContextPath() + "/auth");
}
}
}
}
catch (Exception e) {
message = e.getMessage();
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/message.jsp");
requestDispatcher.include(request, response);
}
}
}
AdminUserGroupServlet
package ru.ksu.eldoc.web;
import ru.ksu.eldoc.services.impl.UserGroupServiceImpl;
import ru.ksu.eldoc.objects.Admin;
import ru.ksu.eldoc.objects.User;
import ru.ksu.eldoc.objects.Group;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException;
import javax.servlet.RequestDispatcher;
import java.io.IOException;
import java.util.List;
public class AdminUserGroupServlet extends HttpServlet {
protected String url;
protected String driver;
protected String user;
protected String password;
public static final String MAIN_PAGE = "mainPage";
public static final String MESSAGE = "message";
public static final String LOGIN = "login";
public static final String PASSWORD = "password";
public static final String USURNAME = "uSurname";
public static final String USERS = "users";
public static final String USER = "user";
public static final String USER_ID = "userId";
public static final String USER_INFO = "userInfo";
public static final String USER_LOGIN = "userLogin";
public static final String USERS_LIST = "usersList";
public static final String EDIT_USER = "editUser";
public static final String DELETE_USER = "deleteUser";
public static final String RESTORE_USER = "restoreUser";
public static final String USER_EDIT = "userEdit";
public static final String USER_SURNAME = "userSurname";
public static final String USER_NAME = "userName";
public static final String USER_PATRONYMIC = "userPatronymic";
public static final String USER_JOB = "userJob";
public static final String USER_EMAIL = "userEmail";
public static final String USER_PASSWORD = "userPassword";
public static final String NEW_USER = "newUser";
public static final String CREATE_NEW_USER = "createNewUser";
public static final String GROUP = "group";
public static final String GROUP_NAME = "groupName";
public static final String CREATE_NEW_GROUP = "createNewGroup";
public static final String GROUPS = "groups";
public static final String GROUPSLIST = "groupsList";
public static final String GROUP_LIST = "groupList";
public static final String NEW_GROUP = "newGroup";
public static final String USERS_IN_GROUP = "usersInGroup";
public static final String DELETE_GROUP = "deleteGroup";
public static final String GROUP_ID = "groupId";
public static final String ADD_TO_GROUP = "addToGroup";
public static final String GROUP_EDIT = "groupEdit";
public static final String EDIT_GROUP = "editGroup";
// public static final String USER_SIZE = "userSize";
public static final String USER_IN_GROUPS = "userInGroups";
public void init() throws ServletException {
super.init();
url = getInitParameter("url");
driver = getInitParameter("driver");
user = getInitParameter("user");
password = getInitParameter("password");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String action = request.getParameter("action");
HttpSession session = request.getSession();
if (action == null) action = MAIN_PAGE;
String message = "";
try {
UserGroupServiceImpl ugsi = new UserGroupServiceImpl(url, driver, user, password);
// FileFolderServiceImpl ffsi = new FileFolderServiceImpl(url, driver, user, password);
// TasksServiceImpl tsi = new TasksServiceImpl(url, driver, user, password);
String login = (String) session.getAttribute(LOGIN);
String pass = (String) session.getAttribute(PASSWORD);
if (action != null) {
if (login == null)
response.sendRedirect(request.getContextPath() + "/auth");
else {
Admin a = new Admin(login, password);
request.setAttribute(USURNAME, a.getLogin());
/* User u = ugsi.getUserInfo(login);
request.setAttribute(USURNAME, u.getSurname());
request.setAttribute(UNAME, u.getName());
request.setAttribute(PATRONYMIC, u.getPatronymic());
request.setAttribute(JOB, u.getJob()); */
if (action.equals(GROUPS)) {
List<Group> groupsList = ugsi.listGroups();
request.setAttribute(GROUPSLIST, groupsList);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminGroups.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(NEW_GROUP)) {
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminNewGroup.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(DELETE_GROUP)) {
String groupId = request.getParameter(GROUP_ID);
Group g = new Group(Long.parseLong(groupId));
ugsi.deleteGroup(g);
response.sendRedirect(request.getContextPath() + "/admin_user_group?action=" + AdminUserGroupServlet.GROUPS);
} else if (action.equals(GROUP_LIST)) {
String groupId = request.getParameter(GROUP_ID);
String groupName = request.getParameter(GROUP_NAME);
Group group = new Group(Long.parseLong(groupId), groupName);
List<User> userList = ugsi.listUsersInGroup(group);
request.setAttribute(USERS_IN_GROUP, userList);
request.setAttribute(GROUP, group);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminGroupList.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(USERS)) {
List<User> users = ugsi.listUsersForAdmin();
request.setAttribute(USERS_LIST, users);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminUsers.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(EDIT_USER)) {
String userId = request.getParameter(USER_ID);
User user = ugsi.getUserInfo(Long.parseLong(userId));
request.setAttribute(USER, user);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminEditUser.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(DELETE_USER)) {
String userId = request.getParameter(USER_ID);
User user = new User(Long.parseLong(userId));
ugsi.deleteUser(user);
response.sendRedirect(request.getContextPath() + "/admin_user_group?action=" + AdminUserGroupServlet.USERS);
} else if (action.equals(RESTORE_USER)) {
String userId = request.getParameter(USER_ID);
User user = new User(Long.parseLong(userId));
ugsi.restoreUser(user);
response.sendRedirect(request.getContextPath() + "/admin_user_group?action=" + AdminUserGroupServlet.USERS);
} else if (action.equals(NEW_USER)) {
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminNewUser.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(USER_INFO)) {
String userId = request.getParameter(USER_ID);
User user = ugsi.getUserInfo(Long.parseLong(userId));
request.setAttribute(USER, user);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminUserInfo.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(USER_IN_GROUPS)) {
String userId = request.getParameter(USER_ID);
User u = ugsi.getUserInfo(Long.parseLong(userId));
User user = new User(Long.parseLong(userId));
List<Group> groups = ugsi.listUserGroups(user);
request.setAttribute(GROUPS, groups);
request.setAttribute(USER, u);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminUserInGroups.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(GROUP_EDIT)) {
String groupId = request.getParameter(GROUP_ID);
String groupName = request.getParameter(GROUP_NAME);
Group group = new Group(Long.parseLong(groupId), groupName);
request.setAttribute(GROUP, group);
List<User> users = ugsi.listUsers();
request.setAttribute(USERS, users);
boolean usersInGroup[] = new boolean[users.size()];
for (int i = 0; i < users.size(); i++) {
User u = users.get(i);
usersInGroup[i] = ugsi.userAreInGroup(u, group);
}
request.setAttribute(USERS_IN_GROUP, usersInGroup);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminEditGroup.jsp");
requestDispatcher.include(request, response);
}
}
}
}
catch (Exception e) {
message = e.getMessage();
// message = "mane page error";
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/message.jsp");
requestDispatcher.include(request, response);
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String action = request.getParameter("action");
HttpSession session = request.getSession();
String message = "";
try {
String login = (String) session.getAttribute(LOGIN);
String pass = (String) session.getAttribute(PASSWORD);
// FileFolderServiceImpl ffsi = new FileFolderServiceImpl(url, driver, user, password);
// TasksServiceImpl tsi = new TasksServiceImpl(url, driver, user, password);
if (action != null) {
if (login == null)
response.sendRedirect(request.getContextPath() + "/auth");
else {
UserGroupServiceImpl ugsi = new UserGroupServiceImpl(url, driver, user, password);
Admin a = new Admin(login, password);
request.setAttribute(USURNAME, a.getLogin());
if (action.equals(USER_EDIT)) {
String uId = request.getParameter(USER_ID);
String uSurname = request.getParameter(USER_SURNAME);
String uName = request.getParameter(USER_NAME);
String uPatronymic = request.getParameter(USER_PATRONYMIC);
String uJob = request.getParameter(USER_JOB);
String uEmail = request.getParameter(USER_LOGIN);
String uPassword = request.getParameter(USER_PASSWORD);
User u = new User(Long.parseLong(uId), uSurname, uName, uPatronymic, uJob, uEmail, uPassword);
int ok = ugsi.editUser(u);
if (ok == 2) {
message = "Пользователь с таким логином уже существует! Пожалуйста, введите другой логин";
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminUserGroupMessage.jsp");
requestDispatcher.include(request, response);
} else if (ok == 1) {
message = "Введенный логин не является адресом электронной почты! Пожалуйста, введите другой логин!!";
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminUserGroupMessage.jsp");
requestDispatcher.include(request, response);
} else if (ok == 0) {
message = "Произошла ошибка!";
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminUserGroupMessage.jsp");
requestDispatcher.include(request, response);
} else
response.sendRedirect(request.getContextPath() + "/admin_user_group?action=" + AdminUserGroupServlet.USERS);
} else if (action.equals(CREATE_NEW_USER)) {
String uSurname = request.getParameter(USER_SURNAME);
String uName = request.getParameter(USER_NAME);
String uPatronymic = request.getParameter(USER_PATRONYMIC);
String uJob = request.getParameter(USER_JOB);
String uEmail = request.getParameter(USER_LOGIN);
String uPassword = request.getParameter(USER_PASSWORD);
User user = new User(uSurname, uName, uPatronymic, uJob, uEmail, uPassword);
int ok = ugsi.addUser(user);
if (ok == 1) {
message = "Введенный логин не является адресом электронной почты! Пожалуйста, введите другой логин!";
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminUserGroupMessage.jsp");
requestDispatcher.include(request, response);
} else if (ok == 2) {
message = "Пользователь с таким логином уже существует! Пожалуйста, введите другой логин!";
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminUserGroupMessage.jsp");
requestDispatcher.include(request, response);
} else
response.sendRedirect(request.getContextPath() + "/admin_user_group?action=" + AdminUserGroupServlet.USERS);
} else if (action.equals(CREATE_NEW_GROUP)) {
String groupName = request.getParameter(GROUP_NAME);
Group g = new Group(groupName);
int ok = ugsi.addGroup(g);
if (ok == 1) {
message = "Группа с таким именем уже существует! Пожалуйста, введите другое имя группы!";
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminUserGroupMessage.jsp");
requestDispatcher.include(request, response);
} else
response.sendRedirect(request.getContextPath() + "/admin_user_group?action=" + AdminUserGroupServlet.GROUPS);
} else if (action.equals(EDIT_GROUP)) {
String groupId = request.getParameter(GROUP_ID);
String groupName = request.getParameter(GROUP_NAME);
Group g = new Group(Long.parseLong(groupId));
String[] userIds = request.getParameterValues("users");
if (userIds != null) {
User[] checkedUsers = new User[userIds.length];
for (int i = 0; i < userIds.length; i++) {
checkedUsers[i] = new User(Long.parseLong(userIds[i]));
}
List<User> allUsers = ugsi.listUsers();
for (int i = 0; i < allUsers.size(); i++) {
User u = allUsers.get(i);
Long uId = u.getId();
boolean checked = false;
for (int j = 0; j < userIds.length; j++) {
if (uId == Long.parseLong(userIds[j])) {
checked = true;
break;
}
}
boolean inGroup = ugsi.userAreInGroup(u, g);
if (checked) {
if (!inGroup) {
ugsi.addUserToGroup(u, g);
}
} else {
if (inGroup)
ugsi.deleteUserFromGroup(u, g);
}
}
} else {
List<User> allUsers = ugsi.listUsers();
for (int i = 0; i < allUsers.size(); i++) {
User u = allUsers.get(i);
boolean inGroup = ugsi.userAreInGroup(u, g);
if (inGroup)
ugsi.deleteUserFromGroup(u, g);
}
}
request.setAttribute(GROUP_ID, groupId);
request.setAttribute(GROUP_NAME, groupName);
response.sendRedirect(request.getContextPath() + "/admin_user_group?action=" + AdminUserGroupServlet.GROUP_LIST + "&" + AdminUserGroupServlet.GROUP_ID + "=" + groupId + "&" + AdminUserGroupServlet.GROUP_NAME + "=" + groupName);
}
}
}
}
catch (Exception
e) {
message = e.getMessage();
// message = "mane page error";
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/message.jsp");
requestDispatcher.include(request, response);
}
}
}
AdminFileFolderTaskServlet
package ru.ksu.eldoc.web;
import ru.ksu.eldoc.services.impl.UserGroupServiceImpl;
import ru.ksu.eldoc.services.impl.FileFolderServiceImpl;
import ru.ksu.eldoc.services.impl.TasksServiceImpl;
import ru.ksu.eldoc.objects.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException;
import javax.servlet.RequestDispatcher;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
public class AdminFileFolderTaskServlet extends HttpServlet {
protected String url;
protected String driver;
protected String user;
protected String password;
// actions
public static final String AFFT = "afft";
public static final String LOGIN = "login";
public static final String PASSWORD = "password";
public static final String MESSAGE = "message";
public static final String USURNAME = "uSurname";
public static final String UNAME = "uName";
public static final String PATRONYMIC = "patronymic";
public static final String JOB = "job";
public static final String USER_ID = "uId";
public static final String FOLDERS = "folders";
public static final String NEW_DOCUMENT = "newDocument";
public static final String NEW_DOCUMENT_IN_FOLDER = "newDocumentInFolder";
public static final String MY_TASKS = "myTasks";
public static final String TASKS = "my_Tasks";
public static final String FOLDER_CONTENTS = "folderContents";
public static final String FOLDER_ID = "folderId";
public static final String FROM_FOLDER = "fromFolder";
public static final String FROM_FOLDER_ID = "fromFolderId";
public static final String ANSWER_DELETE_FOLDER = "deleteFolder";
public static final String DELETE_FOLDER = "deleteFolder";
public static final String DELETE_TASK = "deleteTask";
public static final String DELETE_FILE = "deleteFile";
public static final String FILE_ID = "fileId";
public static final String FILE_INFO = "fileInfo";
public static final String FILEINFO = "fileinfo";
public static final String FOLDER = "folder";
public static final String ADD_FOLDER = "addFolder";
public static final String FOLDER_NAME = "folderName";
public static final String CREATE_NEW_FOLDER = "createNewFolder";
public static final String VERSION = "version";
public static final String VERSION_NUMBER = "versionNumber";
public static final String SHOW_TASKS = "showTasks";
public static final String NEW_TASK = "newTask";
public static final String TASK_ID = "taskId";
public static final String CREATE_NEW_TASK = "createNewTask";
public static final String TASK_TEXT = "taskText";
public static final String SHOW_FILE_ACCESS = "showFileAccess";
public static final String FILE_ACCESS = "fileAccess";
public static final String DELETE_VERSION = "deleteVersion";
public static final String DELETE_ALL_VERSION = "deleteAllVersion";
public void init() throws ServletException {
super.init();
url = getInitParameter("url");
driver = getInitParameter("driver");
user = getInitParameter("user");
password = getInitParameter("password");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String action = request.getParameter("action");
HttpSession session = request.getSession();
UserGroupServiceImpl ugsi;
FileFolderServiceImpl ffsi;
if (action == null) action = AFFT;
String message = "";
try {
String login = (String) session.getAttribute(LOGIN);
String pass = (String) session.getAttribute(PASSWORD);
if (action != null) {
if (login == null)
response.sendRedirect(request.getContextPath() + "/auth");
else {
ffsi = new FileFolderServiceImpl(url, driver, user, password);
TasksServiceImpl tsi = new TasksServiceImpl(url, driver, user, password);
Admin a = new Admin(login, password);
request.setAttribute(USURNAME, a.getLogin());
if (action.equals(ANSWER_DELETE_FOLDER)) {
String folderId = (String) session.getAttribute(FOLDER);
request.setAttribute(FOLDER_ID, folderId);
String folName = ffsi.getNameOfFolder(Long.parseLong(folderId));
request.setAttribute(FOLDER_NAME, folName);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminAnswerDeleteFolder.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(ADD_FOLDER)) {
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminNewFolder.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(FILE_INFO)) {
String fileId = request.getParameter(FILE_ID);
File f = new File(Long.parseLong(fileId));
FileToSee fInfo = ffsi.getInfOfFileToSee(f);
request.setAttribute(FILEINFO, fInfo);
request.setAttribute(FILE_ID, fileId);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminFileInfo.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(DELETE_TASK)) {
String taskId = request.getParameter(TASK_ID);
Tasks t = new Tasks(Long.parseLong(taskId));
tsi.deleteTask(t);
response.sendRedirect(request.getContextPath() + "/afft?action=" + AdminFileFolderTaskServlet.SHOW_TASKS);
} else if (action.equals(NEW_TASK)) {
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminNewTask.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(SHOW_TASKS)) {
List<Tasks> tasks = tsi.showTasks();
request.setAttribute(TASKS, tasks);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminTasks.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(DELETE_FILE)) {
String fileId = request.getParameter(FILE_ID);
ru.ksu.eldoc.objects.File f = new ru.ksu.eldoc.objects.File(Long.parseLong(fileId));
ffsi = new FileFolderServiceImpl(url, driver, user, password);
String path1 = ffsi.getFileUrl(f);
String pathv = "";
java.io.File uploadetFile = new java.io.File(path1);
uploadetFile.delete();
int numb = ffsi.getNumberOfVersions(f);
for (int i = 2; i <= numb; i++) {
int num = path1.indexOf('.');
String sub1 = path1.substring(0, num);
String sub2 = path1.substring(num, path1.length());
String iS = String.valueOf(i);
if (iS.length() == 1)
pathv = sub1 + "#00" + iS + sub2;
else if (iS.length() == 2)
pathv = sub1 + "#0" + iS + sub2;
else if (iS.length() == 3)
pathv = sub1 + "#" + iS + sub2;
uploadetFile = new java.io.File(pathv);
uploadetFile.delete();
}
ffsi.deleteFile(f);
response.sendRedirect(request.getContextPath() + "/admin_main");
} else if (action.equals(VERSION)) {
String fileId = request.getParameter(FILE_ID);
File f = new File(Long.parseLong(fileId));
request.setAttribute(FILE_ID, Long.parseLong(fileId));
FileToSee fInfo = ffsi.getInfOfFileToSee(f);
request.setAttribute(FILEINFO, fInfo);
List<Version> v = ffsi.showVersionOfFile(f);
request.setAttribute(VERSION_NUMBER, v);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminVersion.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(SHOW_FILE_ACCESS)) {
String fileId = request.getParameter(FILE_ID);
request.setAttribute(FILE_ID, fileId);
File f = new File(Long.parseLong(fileId));
FileToSee fInfo = ffsi.getInfOfFileToSee(f);
request.setAttribute(FILEINFO, fInfo);
FileAccess fa = ffsi.showMyFileAccess(f);
request.setAttribute(FILE_ACCESS, fa);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/admin/adminShowFileAccess.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(DELETE_VERSION)) {
String fileId = request.getParameter(FILE_ID);
String number = request.getParameter(VERSION_NUMBER);
ru.ksu.eldoc.objects.File f = new ru.ksu.eldoc.objects.File(Long.parseLong(fileId));
FileInfo fi = new FileInfo(Long.parseLong(fileId));
f.setFileinfo(fi);
int n = (int) Long.parseLong(number);
ffsi = new FileFolderServiceImpl(url, driver, user, password);
int numToPath = ffsi.getNumberToPathOfVersion(f, n);
String path = ffsi.getFileUrl(f);
String pathv = "";
int num = path.indexOf('.');
String sub1 = path.substring(0, num);
String sub2 = path.substring(num, path.length());
String iS = String.valueOf(numToPath);
if (iS.length() == 1)
pathv = sub1 + "#00" + iS + sub2;
else if (iS.length() == 2)
pathv = sub1 + "#0" + iS + sub2;
else if (iS.length() == 3)
pathv = sub1 + "#" + iS + sub2;
java.io.File uploadetFile = new java.io.File(pathv);
uploadetFile.delete();
ffsi.deleteVersion(f, n);
response.sendRedirect(request.getContextPath() + "/afft?action=" + AdminFileFolderTaskServlet.VERSION + "&" + AdminFileFolderTaskServlet.FILE_ID + "=" + fileId);
}
}
}
}
catch (Exception e) {
message = e.getMessage();
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/message.jsp");
requestDispatcher.include(request, response);
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String action = request.getParameter("action");
HttpSession session = request.getSession();
String message = "";
try {
String login = (String) session.getAttribute(LOGIN);
String pass = (String) session.getAttribute(PASSWORD);
if (action != null) {
if (login == null)
response.sendRedirect(request.getContextPath() + "/auth");
else {
UserGroupServiceImpl ugsi = new UserGroupServiceImpl(url, driver, user, password);
FileFolderServiceImpl ffsi = new FileFolderServiceImpl(url, driver, user, password);
TasksServiceImpl tsi = new TasksServiceImpl(url, driver, user, password);
Admin a = new Admin(login, password);
request.setAttribute(USURNAME, a.getLogin());
if (action.equals(CREATE_NEW_TASK)) {
String taskText = request.getParameter(TASK_TEXT);
Tasks newTask = new Tasks(taskText);
tsi.fixTask(newTask);
response.sendRedirect(request.getContextPath() + "/afft?action=" + AdminFileFolderTaskServlet.SHOW_TASKS);
} else if (action.equals("testTree")) {
ffsi = new FileFolderServiceImpl(url, driver, user, password);
String folderId = request.getParameter("dir").replaceAll("\\/", "");
session.removeAttribute(FOLDER);
session.setAttribute(FOLDER, folderId);
long name = 2;
Folder f = new Folder(Long.parseLong(folderId));
FromFolder ff = ffsi.showFoldersAndFilesFromFolder(a, f);
PrintWriter out = response.getWriter();
out.print("<ul class=\"jqueryFileTree\" style=\"display: none;\">");
// All dirs
for (Folder folder: ff.getFolders()) {
out.print("<li class=\"directory collapsed\"><a href=\"#\" rel=\"" + folder.getId() + "/\">"
+ folder.getName() + "</a></li>");
}
// All files
for (File file: ff.getFiles()) {
int dotIndex = file.getName().lastIndexOf('.');
String ext = dotIndex > 0 ? file.getName().substring(dotIndex + 1): "";
out.print("<li class=\"file ext_" + ext + "\"><a href=\"#\" rel=\"" + +file.getId() + "\">"
+ file.getName() + "</a></li>");
}
out.print("</ul>");
} else if (action.equals(DELETE_ALL_VERSION)) {
ffsi = new FileFolderServiceImpl();
String fileId = request.getParameter(FILE_ID);
File f = new File(Long.parseLong(fileId));
FileInfo fi = new FileInfo(Long.parseLong(fileId));
f.setFileinfo(fi);
String[] deletedId = request.getParameterValues("deleted");
if (deletedId != null) {
int n = (int) (Long.parseLong(deletedId[0]));
int numb = ffsi.getNumberOfVersions(f);
String path1 = ffsi.getFileUrl(f);
String pathv = "";
for (int i = 2; i <= numb; i++) {
int numToPath = ffsi.getNumberToPathOfVersion(f, numb);
int num = path1.indexOf('.');
String sub1 = path1.substring(0, num);
String sub2 = path1.substring(num, path1.length());
String iS = String.valueOf(numToPath);
if (iS.length() == 1)
pathv = sub1 + "#00" + iS + sub2;
else if (iS.length() == 2)
pathv = sub1 + "#0" + iS + sub2;
else if (iS.length() == 3)
pathv = sub1 + "#" + iS + sub2;
java.io.File uploadetFile = new java.io.File(pathv);
uploadetFile.delete();
}
ffsi.deleteAllVersion(f, n);
response.sendRedirect(request.getContextPath() + "/afft?action=" + AdminFileFolderTaskServlet.VERSION + "&" + AdminFileFolderTaskServlet.FILE_ID + "=" + fileId);
} else {
response.sendRedirect(request.getContextPath() + "/afft?action=" + AdminFileFolderTaskServlet.VERSION + "&" + AdminFileFolderTaskServlet.FILE_ID + "=" + fileId);
}
} else if (action.equals(CREATE_NEW_FOLDER)) {
String folName = request.getParameter(FOLDER_NAME);
String folderId = (String) session.getAttribute(FOLDER);
Folder topFolder = new Folder(Long.parseLong(folderId));
Folder addFolder = new Folder(folName);
ffsi.addFolder(addFolder, topFolder);
response.sendRedirect(request.getContextPath() + "/admin_main");
} else if (action.equals(DELETE_FOLDER)) {
String folderId = (String) request.getParameter(FOLDER_ID);
Folder f = new Folder(Long.parseLong(folderId));
ffsi.deleteFolder(f);
response.sendRedirect(request.getContextPath() + "/admin_main");
}
}
}
}
catch (Exception e) {
message = e.getMessage();
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/message.jsp");
requestDispatcher.include(request, response);
}
}
}
AdminDownload
package ru.ksu.eldoc.web;
import ru.ksu.eldoc.services.impl.UserGroupServiceImpl;
import ru.ksu.eldoc.services.impl.FileFolderServiceImpl;
import ru.ksu.eldoc.services.impl.TasksServiceImpl;
import ru.ksu.eldoc.objects.User;
import ru.ksu.eldoc.objects.FileToSee;
import ru.ksu.eldoc.objects.Admin;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException;
import javax.servlet.RequestDispatcher;
import java.io.IOException;
import java.io.File;
import java.io.FileInputStream;
public class AdminDownload extends HttpServlet {
protected String url;
protected String driver;
protected String user;
protected String password;
protected String path;
public static final String LOGIN = "login";
public static final String PASSWORD = "password";
public static final String USURNAME = "uSurname";
public static final String UNAME = "uName";
public static final String PATRONYMIC = "patronymic";
public static final String JOB = "job";
public static final String USER_ID = "uId";
public static final String DOWNLOAD = "download";
public static final String DOWNLOAD_FILE = "downloadFile";
public static final String DOWNLOAD_VERSION = "downloadVersion";
public static final String VERSION_NUMBER = "versionNumber";
public static final String FILE_ID = "fileId";
public static final String PATH = "path";
public static final String UPLOADMESSAGE = "message";
public static final String FOLDER_ID = "folderId";
public static final String FILEINFO = "fileinfo";
public void init() throws ServletException {
super.init();
url = getInitParameter("url");
driver = getInitParameter("driver");
user = getInitParameter("user");
password = getInitParameter("password");
path = getInitParameter("rootFolder");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String action = request.getParameter("action");
HttpSession session = request.getSession();
UserGroupServiceImpl ugsi;
FileFolderServiceImpl ffsi;
String message = "";
try {
String login = (String) session.getAttribute(LOGIN);
String pass = (String) session.getAttribute(PASSWORD);
if (action != null) {
if (login == null)
response.sendRedirect(request.getContextPath() + "/auth");
else {
ffsi = new FileFolderServiceImpl(url, driver, user, password);
TasksServiceImpl tsi = new TasksServiceImpl(url, driver, user, password);
Admin a = new Admin(login, password);
request.setAttribute(USURNAME, a.getLogin());
if (action.equals(DOWNLOAD)) {
String fileId = request.getParameter(FILE_ID);
request.setAttribute(FILE_ID, fileId);
String folderId = request.getParameter(FOLDER_ID);
ffsi = new FileFolderServiceImpl(url, driver, user, password);
ru.ksu.eldoc.objects.File file = new ru.ksu.eldoc.objects.File(Long.parseLong(fileId));
FileToSee fInfo = ffsi.getInfOfFileToSee(file);
request.setAttribute(FILEINFO, fInfo);
String path = ffsi.getFileUrl(file);
request.setAttribute(PATH, path);
dowload(request, response, path);
response.sendRedirect(request.getContextPath() + "/afft?action=" + FileFolderTaskServlet.FOLDER_CONTENTS + "&" + FileFolderTaskServlet.FOLDER_ID + "=" + folderId);
// RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/downloadFile.jsp");
// requestDispatcher.include(request, response);
} else if (action.equals(DOWNLOAD_VERSION)) {
String fileId = request.getParameter(FILE_ID);
request.setAttribute(FILE_ID, fileId);
String number = request.getParameter(VERSION_NUMBER);
ffsi = new FileFolderServiceImpl(url, driver, user, password);
ru.ksu.eldoc.objects.File file = new ru.ksu.eldoc.objects.File(Long.parseLong(fileId));
int numberToPath = ffsi.getNumberToPathOfVersion(file, Integer.parseInt(number));
String path = ffsi.getFileUrl(file);
String pathv = "";
int num = path.indexOf('.');
String sub1 = path.substring(0, num);
String sub2 = path.substring(num, path.length());
String iS = String.valueOf(numberToPath);
if (iS.length() == 1)
pathv = sub1 + "#00" + iS + sub2;
else if (iS.length() == 2)
pathv = sub1 + "#0" + iS + sub2;
else if (iS.length() == 3)
pathv = sub1 + "#" + iS + sub2;
dowload(request, response, pathv);
response.sendRedirect(request.getContextPath() + "/afft?action=" + AdminFileFolderTaskServlet.VERSION + "&" + AdminFileFolderTaskServlet.FILE_ID + "=" + fileId);
}
}
}
}
catch (Exception e) {
message = e.getMessage();
// message = "mane page error";
request.setAttribute(UPLOADMESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/uploadMessage.jsp");
requestDispatcher.include(request, response);
}
}
private void dowload(HttpServletRequest request, HttpServletResponse response, String path) throws IOException {
File file = new File(path);
FileInputStream fin = new FileInputStream(file);
int available = fin.available();
byte[] buffer = new byte[available];
fin.read(buffer);
fin.close();
int num = path.indexOf('.');
String sub2 = path.substring(num + 1, path.length());
if (sub2.equals("doc"))
response.setContentType("application/msword");
else if (sub2.equals("jpg") || sub2.equals("JPG"))
response.setContentType("image/jpg");
else if (sub2.equals("bmp"))
response.setContentType("image/bmp");
else if (sub2.equals("xls"))
response.setContentType("application/vnd.ms-excel");
else if (sub2.equals("pdf"))
response.setContentType("application/pdf");
else if (sub2.equals("gif"))
response.setContentType("image/gif");
else if (sub2.equals("zip"))
response.setContentType("application/zip");
else if (sub2.equals("ppt"))
response.setContentType("application/vnd.ms-powerpoint");
else if (sub2.equals("txt"))
response.setContentType("text/plain");
response.getOutputStream().write(buffer);
response.getOutputStream().close();
}
}
ПРИЛОЖЕНИЕ 3
Контроллер, отвечающий за работу обычного пользователя
MainPageServlet
package ru.ksu.eldoc.web;
import ru.ksu.eldoc.objects.*;
import ru.ksu.eldoc.services.impl.FileFolderServiceImpl;
import ru.ksu.eldoc.services.impl.UserGroupServiceImpl;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException;
import javax.servlet.RequestDispatcher;
import java.io.IOException;
import java.util.List;
public class MainPageServlet extends HttpServlet {
protected String url;
protected String driver;
protected String user;
protected String password;
// actions
public static final String MAIN_PAGE = "mainPage";
// parameters
public static final String LOGIN = "login";
public static final String PASSWORD = "password";
public static final String EXIT = "exit";
public static final String MESSAGE = "message";
public static final String USURNAME = "uSurname";
public static final String UNAME = "uName";
public static final String PATRONYMIC = "patronymic";
public static final String JOB = "job";
public static final String FOLDERS = "folders";
public static final String NEW_DOCUMENT = "newDocument";
public static final String MY_TASKS = "myTasks";
public static final String TASKS = "my_Tasks";
public static final String GROUPS = "groups";
public static final String GROUPSLIST = "groupsList";
public static final String GROUP_LIST = "groupList";
public static final String USERS_IN_GROUP = "usersInGroup";
public static final String GROUP_ID = "groupId";
public static final String FOLDER_CONTENTS = "folderContents";
public static final String FOLDER_ID = "folderId";
public static final String FROM_FOLDER = "fromFolder";
public void init() throws ServletException {
super.init();
url = getInitParameter("url");
driver = getInitParameter("driver");
user = getInitParameter("user");
password = getInitParameter("password");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String action = request.getParameter("action");
HttpSession session = request.getSession();
UserGroupServiceImpl ugsi;
FileFolderServiceImpl ffsi;
if (action == null) action = MAIN_PAGE;
String message = "";
try {
String login = (String) session.getAttribute(LOGIN);
String pass = (String) session.getAttribute(PASSWORD);
if (action != null) {
if (login == null)
response.sendRedirect(request.getContextPath() + "/auth");
else {
ugsi = new UserGroupServiceImpl(url, driver, user, password);
User u = ugsi.getUserInfo(login);
request.setAttribute(USURNAME, u.getSurname());
request.setAttribute(UNAME, u.getName());
request.setAttribute(PATRONYMIC, u.getPatronymic());
request.setAttribute(JOB, u.getJob());
if (action.equals(MAIN_PAGE)) {
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/mainPage.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(EXIT)) {
session.removeAttribute(LOGIN);
session.removeAttribute(PASSWORD);
response.sendRedirect(request.getContextPath() + "/auth");
}
}
}
}
catch (Exception e) {
message = e.getMessage();
request.setAttribute(MESSAGE, message);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/message.jsp");
requestDispatcher.include(request, response);
}
}
}
UserGroupServlet
package ru.ksu.eldoc.web;
import ru.ksu.eldoc.services.impl.UserGroupServiceImpl;
import ru.ksu.eldoc.objects.Group;
import ru.ksu.eldoc.objects.User;
import javax.servlet.ServletException;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
/**
* Created by IntelliJ IDEA.
* User: Leno4ka
* Date: 26.05.2010
* Time: 18:59:21
* To change this template use File | Settings | File Templates.
*/
public class UserGroupServlet extends HttpServlet {
protected String url;
protected String driver;
protected String user;
protected String password;
public static final String MAIN_PAGE = "mainPage";
public static final String MESSAGE = "message";
public static final String LOGIN = "login";
public static final String PASSWORD = "password";
public static final String USURNAME = "uSurname";
public static final String UNAME = "uName";
public static final String PATRONYMIC = "patronymic";
public static final String JOB = "job";
public static final String USERS = "users";
public static final String USER = "user";
public static final String USER_ID = "userId";
public static final String USER_INFO = "userInfo";
public static final String USER_LOGIN = "userLogin";
public static final String USERS_LIST = "usersList";
public static final String USER_SURNAME = "userSurname";
public static final String USER_NAME = "userName";
public static final String USER_PATRONYMIC = "userPatronymic";
public static final String USER_JOB = "userJob";
public static final String USER_EMAIL = "userEmail";
public static final String GROUP = "group";
public static final String GROUP_NAME = "groupName";
public static final String GROUPS = "groups";
public static final String GROUPSLIST = "groupsList";
public static final String GROUP_LIST = "groupList";
public static final String USERS_IN_GROUP = "usersInGroup";
public static final String GROUP_ID = "groupId";
public static final String USER_IN_GROUPS = "userInGroups";
public void init() throws ServletException {
super.init();
url = getInitParameter("url");
driver = getInitParameter("driver");
user = getInitParameter("user");
password = getInitParameter("password");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String action = request.getParameter("action");
HttpSession session = request.getSession();
if (action == null) action = MAIN_PAGE;
String message = "";
try {
UserGroupServiceImpl ugsi = new UserGroupServiceImpl(url, driver, user, password);
String login = (String) session.getAttribute(LOGIN);
String pass = (String) session.getAttribute(PASSWORD);
if (action != null) {
if (login == null)
response.sendRedirect(request.getContextPath() + "/auth");
else {
ugsi = new UserGroupServiceImpl(url, driver, user, password);
User u = ugsi.getUserInfo(login);
request.setAttribute(USURNAME, u.getSurname());
request.setAttribute(UNAME, u.getName());
request.setAttribute(PATRONYMIC, u.getPatronymic());
request.setAttribute(JOB, u.getJob());
if (action.equals(GROUPS)) {
List<Group> groupsList = ugsi.listGroups();
request.setAttribute(GROUPSLIST, groupsList);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/groups.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(GROUP_LIST)) {
String groupId = request.getParameter(GROUP_ID);
Group group = new Group(Long.parseLong(groupId));
String groupName = ugsi.getGroupName(group);
group.setName(groupName);
List<User> userList = ugsi.listUsersInGroup(group);
request.setAttribute(USERS_IN_GROUP, userList);
request.setAttribute(GROUP, group);
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/jsp/groupList.jsp");
requestDispatcher.include(request, response);
} else if (action.equals(USERS)) {
List<User> users = ugsi.listUsersForAdmin();
Подобные документы
Процесс создания программы для электронного документооборота учреждения. Оценка ее качественных и количественных показателей. Выбор аппаратной и программной платформы Web-сайта. Разработка функциональной схемы обработки документов и доступа пользователей.
дипломная работа [233,9 K], добавлен 02.10.2013Значение документооборота как средства для управления предприятием. Организации системы электронного документооборота и требований, предъявляемых к системам. Проблема выбора системы электронного документооборота на предприятиях малого и среднего бизнеса.
контрольная работа [31,8 K], добавлен 14.09.2015Аппаратное, сетевое, программное обеспечение предприятия. Разработка системы электронного документооборота. Последовательность создания и технология построения информационной системы. Выбор системы управления базами данных, среды разработки приложения.
дипломная работа [1,5 M], добавлен 15.10.2013Назначение системы электронного документооборота. Построение функциональной модели поставки товаров в супермаркет. Основные свойства системы электронного документооборота ООО "Ксенокс". Особенности проектирования системы обеспечения продукцией в BPwin.
курсовая работа [1,4 M], добавлен 15.01.2010Современные электронные системы управления и работы с документами. Проблемы традиционных и электронных технологий ДОУ. Выбор эффективной СЭУД (классификация систем электронного управления документами). Защищенность электронного документооборота.
дипломная работа [124,9 K], добавлен 12.12.2007Задачи системы электронного документооборота. Анализ существующих информационных систем. Методы и средства инженерии программного обеспечения. Концептуальная модель данных в BPWin. Построение инфологической модели системы документооборота "Doc_Univer".
курсовая работа [56,1 K], добавлен 25.03.2014Основные понятия и преимущества электронного документооборота над бумажным. Проблемы внедрения системы, реализация электронного документооборота. Обеспечение подготовки, автоматизация, форматы и стандарты обмена. Обеспечение гарантированной доставки.
реферат [1,0 M], добавлен 23.02.2011Понятие системы электронного документооборота. Документ - способ упорядочения информации. Современные системы электронного оборота документации и их технические возможности. Обзор разработчиков СЭД. Глобальные государственные инициативы в этой сфере.
реферат [1,5 M], добавлен 09.12.2013Решения по разработке системы электронного документооборота, государственные инициативы и стандарты в данной области, существующие проблемы и направления их разрешения. Модель данных общей и пользовательской части, принципы разработки интерфейса.
дипломная работа [1,9 M], добавлен 20.12.2013Принципы организации документооборота управленческой деятельности. Создание компонентов систем электронного документооборота. Directum: краткое описание системы, решаемые задачи, архитектура. Безопасные приемы работы. Виды опасных и вредных факторов.
дипломная работа [1,7 M], добавлен 17.03.2013