Главная страница
Навигация по странице:

  • СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ

  • ПРИЛОЖЕНИЕ А

  • ПРИЛОЖЕНИЕ В

  • Разработка автоматизированной системы для документооборота. Реферат вопрос о необходимости автоматизации управления документооборотом давно перешел в практическую плоскость, и все больше российских предприятий внедряют у себя системы электронного документооборота,


    Скачать 3.12 Mb.
    НазваниеРеферат вопрос о необходимости автоматизации управления документооборотом давно перешел в практическую плоскость, и все больше российских предприятий внедряют у себя системы электронного документооборота,
    АнкорРазработка автоматизированной системы для документооборота
    Дата21.06.2022
    Размер3.12 Mb.
    Формат файлаpdf
    Имя файлаm_th_nechukhin_2014.pdf
    ТипРеферат
    #607275
    страница12 из 12
    1   ...   4   5   6   7   8   9   10   11   12
    ЗАКЛЮЧЕНИЕ
    В ходе выполнения работы была разработана онлайн автоматизированная система электронного документооборота, также интегрирована CMS-система управления контентом и интеллектуальный анализ данных. Онлайн-система написана на мультиплатформенном языке программирования Java. Она имеет интуитивно понятный интерфейс.
    Система электронного документооборота предусматривает два режима работы: администратора и обычного пользователя. Реализованы возможности работы с документами, их загрузка и редактирование, добавление новых версий и назначение заданий для выполнения пользователями, предусмотрена работа с группами пользователей.
    При работе с документами реализована возможность редактирования доступа к файлу.
    Пользователь, добавивший документ, может задать область видимости, указав группы и пользователей, которым будет доступен файл. Лица из этого списка могут просматривать файл, скачивать его, добавлять к нему задания и редактировать версии файла (добавлять новые, удалять существующие).
    Кроме того, в системе реализована рассылка оповещений. При добавлении задания определенному пользователю, он получает оповещение об этом на почту.
    Созданное приложение легко в освоении, удобно в использовании и оперативном получении информации.
    Прототип системы документооборота, организованный по модульной архитектуре, может быть легко доработан до коммерческого предложения.
    Данная работа помимо этого подразумевала учебную цель: ознакомление с Java Server-Side
    – технологиями. При разработке системы были использованы современные информационные технологии: JavaEE - JSP, Servlets, JSP, JDBC; технология AJAX. Цель была достигнута.
    Система электронного документооборота может иметь свое практическое применение, как в средних, так и в крупных организациях, где требуется ведение большого объема документов.

    123
    СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ
    1. Библиотека MSDN. Источник информации для разработчиков, использующих средства, продукты, технологии и службы корпорации Майкрософт.[Электронный ресурс]. – Режим доступа: http://msdn.microsoft.com
    2. КиберФорум. Форум начинающих и профессиональных программистов, системных администраторов, администраторов баз данных. [Электронный ресурс]. – Режим доступа: http://cyberforum.ru
    3. ИНТУИТ. Интернет университет информационных технологий.[Электронный ресурс]. –
    Режим доступа: http://intuit.ru
    4. Клуб программистов. [Электронный ресурс]. – Режим доступа: http://www.cyberguru.ru/
    5. Code Project. Сообщество разработки программного обеспечения.[Электронный ресурс]. –
    Режим доступа: http://codeproject.com
    6. ВикипедиЯ. Свободная энциклопедия. [Электронный ресурс]. – Режим доступа: http://ru.wikipedia.org/wiki
    7. Дж. Боуман, С. Эмерсон, М. Дарновски Практическое руководство по SQL, 4-е изд.: Пер.с англ. – М.: Издательский дом "Вильямс", 2002 8. Философия Java. Библиотека программиста. 5-е изд. - СПб.: Питер, 2012 9. Java2. Библиотека профессионала, том 1. Основы, 8-е изд.: Пер. с англ. - М.: Издательский дом "Вильямс", 2012 10. Java2. Библиотека профессионала, том 2. Тонкости программирования, 8-е изд.: Пер. с англ. -
    М.: Издательский дом "Вильямс", 2013 11. Л. Веллинг. Разработка WEB-приложений с помощью PHP и MySQL. 2-е издание.: Пер. с англ. – М.: Издательский дом «Вильямс», 2041.-800с
    12. Хомоненко А.Д., Цыганков В.М., Мальцев М.Г. – Базы данных: учебник для высших учебных заведений/ Под ред. Проф. А.Д.Хомоненко.-6-е изд., СПб.:КОРОНА принт, 2011.-
    736 с.
    13. Иванов А.В. Критерии оценки быстродействия CMS. [Электронный ресурс]. – Режим доступа: http://www.cmslist.ru
    14. Красильникова О.В. Обзор рынка CMS. [Электронный ресурс]. – Режим доступа: http://rucms.ru/visit.php?url=http://mdesign.ru
    15. Лозовюк А.В. Анатомия CMS. [Электронный ресурс]. – Режим доступа: http://www.hostinfo.ru/

    124
    ПРИЛОЖЕНИЕ А
    Программный код контроллера, отвечающего за аутентификацию:
    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);
    }
    }

    125 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);
    }
    }
    }
    }
    Программный код контроллера, отвечающего за работу администратора:
    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;

    126 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";

    127 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);
    }
    }
    }

    128
    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";

    129 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 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 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)) {

    130
    List 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 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 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";

    131 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);

    132
    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 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)

    133 ugsi.deleteUserFromGroup(u, g);
    }
    }
    } else {
    List 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";

    134 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 {

    135 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 = 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);

    136 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 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);
    }
    }

    137 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);

    138 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("
      ");
      // All dirs for (Folder folder: ff.getFolders()) { out.print("
    • "
      + folder.getName() + "
    • ");
      }
      // All files for (File file: ff.getFiles()) { int dotIndex = file.getName().lastIndexOf('.');
      String ext = dotIndex > 0 ? file.getName().substring(dotIndex + 1): ""; out.print("
    • "
      + file.getName() + "
    • ");
      } out.print("
    ");
    } 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;

    139 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;

    140 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);

    141 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");

    142 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();
    }
    }
    Программный код служебных классов, отвечающих за рассылку оповещений на электронную почту:
    MailLogger package ru.ksu.eldoc.web; import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import java.util.Properties; public class MailLogger { private static final String SMTP_HOST_NAME = "smtp.mail.ru"; private static final String subject = "Log Message"; private static final String from = "lenakonfeta88@mail.ru";
    // Add List of Email address to who email needs to be sent to private static final String[] recipients = {"lenakonfeta88@mail.ru"}; public void postMail(String message, String recipient) throws MessagingException { boolean debug = false;
    //Set the host smtp address
    Properties props = new Properties(); props.put("mail.smtp.host", SMTP_HOST_NAME); props.put("mail.smtp.auth", "true");
    Authenticator auth = new SMTPAuthenticator();
    Session session = Session.getDefaultInstance(props, auth); session.setDebug(debug);
    // create a message
    Message msg = new MimeMessage(session);
    // set the from and to address
    InternetAddress addressFrom = new InternetAddress(from); msg.setFrom(addressFrom);
    InternetAddress addressTo = new InternetAddress(recipient); msg.setRecipient(Message.RecipientType.TO, addressTo);
    // Setting the Subject and Content Type msg.setSubject(subject); msg.setContent(message, "text/plain; charset=windows-1251");
    Transport.send(msg);
    }
    }
    SMTPAuthenticator package ru.ksu.eldoc.web;

    143 import javax.mail.Authenticator; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import java.util.Properties; import javax.mail.PasswordAuthentication; public class SMTPAuthenticator extends Authenticator { private static final String SMTP_AUTH_USER = "lenakonfeta88"; private static final String SMTP_AUTH_PWD = "zgecmrf"; public PasswordAuthentication getPasswordAuthentication() {
    String username = SMTP_AUTH_USER;
    String password = SMTP_AUTH_PWD; return new PasswordAuthentication(username, password); } }
    Приложение 5
    Описание некоторых функций из ключевых сервисов по работе с БД
    Показатьсписокфайловизпапки public List showFilesFromFolder (User user, Folder folder) throws ClassNotFoundException, IOException,
    SQLException {
    Connection connection = getConnection();
    PreparedStatement statement;
    File f;
    List result = new ArrayList(); boolean allow = false; try { statement = connection.prepareStatement("SELECT fileId FROM FILES WHERE folderId=?"); statement.setLong(1, folder.getId());
    ResultSet resultSet = statement.executeQuery(); while (resultSet.next()) { long fileId = resultSet.getLong("fileId"); statement = connection.prepareStatement("SELECT fullAccess FROM FILES WHERE fileId=?"); statement.setLong(1, fileId);
    ResultSet resultSet2 = statement.executeQuery(); resultSet2.next(); int fullAccess = resultSet2.getInt("fullAccess"); if (fullAccess == 1) allow = true; else { statement = connection.prepareStatement("SELECT ga.fileId FROM GROUPACCESS ga, GROUPSLIST gl
    WHERE ga.fileId=? AND gl.userId=? AND ga.groupId=gl.groupId"); statement.setLong(1, fileId); statement.setLong(2, user.getId()); resultSet2 = statement.executeQuery(); if (resultSet2.next()) allow = true; else { statement = connection.prepareStatement("SELECT * FROM USERACCESS WHERE fileId=? AND userId=?"); statement.setLong(1, fileId); statement.setLong(2, user.getId()); resultSet2 = statement.executeQuery(); if (resultSet2.next()) allow = true;
    }
    } if (allow == true) { statement = connection.prepareStatement("SELECT fName, comment, url, addDate, size, dayOfStorage, folderId, fi.userId, surname, uName, patronymic, job FROM FILES f, FILEINFO fi, USERS u WHERE fileId=? AND fi.userId=u.userId"); statement.setLong(1, fileId); resultSet2 = statement.executeQuery();

    144 resultSet2.next();
    String fName = resultSet2.getString("fName");
    String comment = resultSet2.getString("comment");
    String url = resultSet2.getString("url");
    String surname = resultSet2.getString("surname");
    String uName = resultSet2.getString("uName");
    String patronymic = resultSet2.getString("patronymic");
    String job = resultSet2.getString("job");
    Long size = resultSet2.getLong("size");
    Long dayOfStorage = resultSet2.getLong("dayOfStorage");
    Long folderId = resultSet2.getLong("folderId");
    Long userId = resultSet2.getLong("userId");
    User u = new User(userId, surname, uName, patronymic, job);
    FileInfo fi = new FileInfo(u, size, dayOfStorage);
    Folder fol = new Folder(folderId, folder.getName()); f = new File(fileId, fName, comment, fol, fi, url); result.add(f); allow = false;
    } resultSet2.close();
    } resultSet.close();
    } catch (SQLException sqle) {
    System.out.println("Ошибка showFilesFromFolder!"); sqle.printStackTrace(); throw sqle;
    } finally { connection.close();
    } return result;
    }
    Установитьверсиюфайла public void setVersionOfFile(File file, User user, String comment) throws IOException, ClassNotFoundException,
    SQLException {
    Connection connection = getConnection();
    PreparedStatement statement; try { connection.setAutoCommit(false); statement = connection.prepareStatement("SELECT numberOfVersion, numberToPath FROM FILEINFO WHERE fileId=?"); statement.setLong(1, file.getId());
    ResultSet resultSet = statement.executeQuery(); resultSet.next(); int numb = resultSet.getInt("numberOfVersion"); int numbtoP = resultSet.getInt("numberToPath"); statement = connection.prepareStatement("INSERT INTO VERSIONS (fileId, version, userId, addDate, comment, numberToPath) values (?, ?,?, ?,?, ?)"); statement.setLong(1, file.getId()); statement.setInt(2, numb + 1); statement.setLong(3, user.getId()); statement.setTimestamp(4, new Timestamp(new Date().getTime())); statement.setString(5, comment); statement.setInt(6, numbtoP + 1); statement.execute(); statement = connection.prepareStatement("UPDATE FILEINFO SET numberOfVersion=?, numberToPath=?
    WHERE fileId=?"); statement.setLong(1, numb + 1); statement.setLong(2, numbtoP + 1); statement.setLong(3, file.getId());

    145 statement.execute(); connection.commit();
    } catch (SQLException sqle) { sqle.printStackTrace(); throw sqle;
    } finally { connection.close();
    }
    }
    Удалить выбранную версию файла public void deleteVersion(File file, int number) throws IOException, ClassNotFoundException, SQLException {
    Connection connection = getConnection();
    PreparedStatement statement; try { connection.setAutoCommit(false); statement = connection.prepareStatement("DELETE FROM VERSIONS WHERE fileId=? AND version=?"); statement.setLong(1, file.getId()); statement.setInt(2, number); statement.execute(); statement = connection.prepareStatement("SELECT version FROM VERSIONS WHERE fileId=? AND version>? "); statement.setLong(1, file.getId()); statement.setInt(2, number);
    ResultSet resultSet = statement.executeQuery(); while (resultSet.next()) { int versionNumb = resultSet.getInt("version"); statement = connection.prepareStatement("UPDATE VERSIONS SET version=? WHERE fileId=? AND version=?"); statement.setInt(1, versionNumb - 1); statement.setLong(2, file.getId()); statement.setLong(3, versionNumb); statement.execute();
    } int numb = getNumberOfVersions(file); statement = connection.prepareStatement("UPDATE FILEINFO SET numberOfVersion=? WHERE fileId=?"); statement.setInt(1, numb - 1); statement.setLong(2, file.getId()); statement.execute(); connection.commit();
    System.out.println("Всеверсии, кромезаданной, удалены");
    } catch (SQLException sqle) { connection.rollback();
    System.out.println("Ошибка deletVersion!"); sqle.printStackTrace(); throw sqle;
    } finally {connection.close();}
    }
    Удалитьзаданиекфайлу public void deleteTaskFromFile(MyTask myTask) throws IOException, ClassNotFoundException, SQLException {
    Connection connection = getConnection();
    PreparedStatement statement; try { connection.setAutoCommit(false); statement = connection.prepareStatement("SELECT taskOrder FROM MYTASKS WHERE myTaskId=?"); statement.setLong(1, myTask.getId());
    ResultSet resultSet = statement.executeQuery(); resultSet.next(); int taskOrd = resultSet.getInt("taskOrder"); long fileId = myTask.getFile().getId();

    146 statement = connection.prepareStatement("SELECT myTaskId, taskOrder FROM MYTASKS WHERE taskOrder>?
    AND fileId=?"); statement.setLong(1, taskOrd); statement.setLong(2, fileId);
    ResultSet resultSet1 = statement.executeQuery(); while (resultSet1.next()) { int id = resultSet1.getInt("myTaskId"); int taskOrd1 = resultSet1.getInt("taskOrder"); statement = connection.prepareStatement("UPDATE MYTASKS SET taskOrder=? WHERE myTaskId=?"); statement.setLong(1, taskOrd1 - 1); statement.setLong(2, id);
    } statement = connection.prepareStatement("DELETE FROM MYTASKS WHERE myTaskId=?"); statement.setLong(1, myTask.getId()); statement.execute(); connection.commit();
    System.out.println("Заданиекфайлууспешноудалено");
    } catch (SQLException sqle) { connection.rollback();
    System.out.println("Ошибка!"); sqle.printStackTrace(); throw sqle;
    } finally {connection.close();}
    }

    147
    ПРИЛОЖЕНИЕ В
    Ксерокопия сертификата участия в международной научно-практической конференции
    «Тенденции формирования науки нового времени», проходившей 27-28 декабря 2013 года, г.Уфа:
    Ксерокопия статьи (часть 1), опубликованной в сборнике статей международной научно- практической конференции, проходившей 27-28 декабря 2013 года, г.Уфа:

    148
    Ксерокопия статьи (часть 2), опубликованной в сборнике статей международной научно- практической конференции, проходившей 27-28 декабря 2013 года, г.Уфа:
    1   ...   4   5   6   7   8   9   10   11   12


    написать администратору сайта