001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.web.controllers;
034:
035: import org.libresource.Libresource;
036:
037: import org.libresource.kernel.KernelConstants;
038: import org.libresource.kernel.interfaces.KernelService;
039:
040: import org.libresource.web.Controller;
041:
042: import java.net.URI;
043:
044: import javax.servlet.http.HttpServletRequest;
045: import javax.servlet.http.HttpServletResponse;
046:
047: public class ServerConfigController implements Controller {
048: public Object process(URI uri, HttpServletRequest request,
049: HttpServletResponse response) throws Exception {
050: KernelService kernelService = (KernelService) Libresource
051: .getService(KernelConstants.SERVICE);
052:
053: // MembershipService membershipService = (MembershipService)
054: // Libresource.getService("Membership");
055: String action = request.getParameter("action");
056:
057: if (action == null) {
058: action = "view";
059: }
060:
061: // view
062: if (action.equals("view")) {
063: request.setAttribute("registerUsers", kernelService
064: .getProperty(kernelService.getServerConfigURI(),
065: "register-users"));
066:
067: return "/pages/serverConfig.jsp";
068: }
069:
070: // edit
071: if (action.equals("edit")) {
072: String registerUsers = request
073: .getParameter("registerUsers");
074:
075: if (registerUsers == null) {
076: request.setAttribute("registerUsers", kernelService
077: .getProperty(
078: kernelService.getServerConfigURI(),
079: "register-users"));
080:
081: return "/pages/serverConfig.jsp";
082: }
083:
084: if (registerUsers.trim().length() != 0) {
085: if (!kernelService.exist(new URI(registerUsers))) {
086: request.setAttribute("registerUsers", kernelService
087: .getProperty(kernelService
088: .getServerConfigURI(),
089: "register-users"));
090: request.setAttribute("configError", registerUsers
091: + " does not exist");
092:
093: return "/pages/serverConfig.jsp";
094: }
095:
096: kernelService.setProperty(kernelService
097: .getServerConfigURI(), "register-users",
098: kernelService.normalizeAbsoluteURIPath(new URI(
099: registerUsers)));
100:
101: return kernelService.getServerConfigURI();
102: }
103:
104: kernelService.setProperty(kernelService
105: .getServerConfigURI(), "register-users", "");
106:
107: return kernelService.getServerConfigURI();
108: }
109:
110: return new URI("/");
111: }
112: }
|