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.core;
034:
035: import org.libresource.Libresource;
036:
037: import org.libresource.core.CoreConstants;
038: import org.libresource.core.ejb.model.TimelineResourceValue;
039: import org.libresource.core.interfaces.LibresourceCoreService;
040:
041: import org.libresource.kernel.KernelConstants;
042: import org.libresource.kernel.LibresourceSecurityException;
043: import org.libresource.kernel.interfaces.KernelService;
044:
045: import org.libresource.web.Controller;
046:
047: import java.net.URI;
048:
049: import javax.servlet.http.HttpServletRequest;
050: import javax.servlet.http.HttpServletResponse;
051:
052: public class EditTimelineController implements Controller {
053: public Object process(URI uri, HttpServletRequest request,
054: HttpServletResponse response) throws Exception {
055: if (request.getParameter("cancel") != null) {
056: return uri;
057: }
058:
059: if (request.getParameter("uriPattern") == null) {
060: KernelService kernelService = (KernelService) Libresource
061: .getService(KernelConstants.SERVICE);
062:
063: if (!kernelService.checkSecurity(uri,
064: KernelConstants.SECURITY_UPDATE)) {
065: throw new LibresourceSecurityException(uri,
066: KernelConstants.SECURITY_UPDATE);
067: }
068:
069: LibresourceCoreService libresourceCoreService = (LibresourceCoreService) Libresource
070: .getService(CoreConstants.SERVICE);
071: TimelineResourceValue timelineResourceValue = libresourceCoreService
072: .getTimeline(uri);
073: request.setAttribute("name", timelineResourceValue
074: .getName());
075: request.setAttribute("uriPattern", timelineResourceValue
076: .getRootURI().replaceAll("%", "\\*"));
077: request.setAttribute("loggedEvents", timelineResourceValue
078: .getLoggedEvents());
079: request.setAttribute("publicEvents", String
080: .valueOf(timelineResourceValue.getPublicEvents()));
081:
082: return "/pages/modules/core/editTimeline.jsp";
083: }
084:
085: boolean publicEvents = false;
086:
087: if ((request.getParameter("publicEvents") != null)
088: && (request.getParameter("publicEvents")
089: .compareTo("on") == 0)) {
090: publicEvents = true;
091: }
092:
093: LibresourceCoreService libresourceCoreService = (LibresourceCoreService) Libresource
094: .getService(CoreConstants.SERVICE);
095: libresourceCoreService.editTimeline(uri, request
096: .getParameter("name"), request
097: .getParameter("uriPattern"), publicEvents);
098:
099: return uri;
100: }
101: }
|