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.so6;
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.so6.core.client.ClientIServletImpl;
041: import org.libresource.so6.server.ls.LibresourceSynchronizerConstants;
042: import org.libresource.so6.server.ls.ejb.model.WsConnectionResourceValue;
043: import org.libresource.so6.server.ls.interfaces.LibresourceSynchronizerService;
044:
045: import org.libresource.web.Controller;
046:
047: import java.io.File;
048:
049: import java.net.URI;
050:
051: import javax.servlet.http.HttpServletRequest;
052: import javax.servlet.http.HttpServletResponse;
053:
054: public class UpdateLocalReplicaController implements Controller {
055: public Object process(URI uri, HttpServletRequest request,
056: HttpServletResponse response) throws Exception {
057: LibresourceSynchronizerService libresourceSynchronizerService = (LibresourceSynchronizerService) Libresource
058: .getService(LibresourceSynchronizerConstants.SERVICE);
059: WsConnectionResourceValue value = libresourceSynchronizerService
060: .getWorkspaceConnection(uri);
061:
062: // Otherwise: if Unix server/Windows client -> file with no parent !!!
063: File wscPath = new File(value.getWsPath().replaceAll("\\\\",
064: "/"));
065:
066: // take care of the security
067: String protocol = "http";
068: String clientName = ClientIServletImpl.class.getName();
069:
070: if (request.isSecure()) {
071: protocol = "https";
072: }
073:
074: // SO6 default
075: request.setAttribute("queueId", libresourceSynchronizerService
076: .getWorkspaceConnectionSynchronizer(uri).getUri()
077: .getPath());
078: request.setAttribute("login", "");
079: request.setAttribute("password", "");
080: request.setAttribute("connectionId", uri);
081:
082: // WsConnection default
083: request.setAttribute("wscPath", wscPath.getPath());
084: request.setAttribute("dataPath", wscPath.getParent());
085: request.setAttribute("basePath", wscPath.getParentFile()
086: .getParentFile().getParent());
087: request.setAttribute("clientName", clientName);
088: request.setAttribute("wscName", value.getName());
089:
090: // Client specific props
091: // servlet -->
092: request.setAttribute("soapEndpoint", protocol + "://"
093: + request.getServerName() + ":"
094: + request.getServerPort() + request.getContextPath()
095: + "/ls-so6/services/so6");
096:
097: // soap -->
098: request.setAttribute("servletEndpoint", protocol + "://"
099: + request.getServerName() + ":"
100: + request.getServerPort() + request.getContextPath()
101: + "/ls-so6/so6");
102:
103: KernelService kernelService = (KernelService) Libresource
104: .getService(KernelConstants.SERVICE);
105: request.setAttribute("encoding", libresourceSynchronizerService
106: .getSynchronizer(kernelService.getParent(uri))
107: .getFileEncoding());
108:
109: return "/pages/modules/so6/jnlp/updateLocalReplicaData.jsp";
110: }
111: }
|