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.so6.server.ls;
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.server.ls.ejb.model.WsConnectionResourceValue;
041: import org.libresource.so6.server.ls.interfaces.LibresourceSynchronizerService;
042:
043: import org.libresource.xml.ImportExportLogger;
044: import org.libresource.xml.LibresourceExportHandler;
045: import org.libresource.xml.XmlDumpHelper;
046:
047: import org.xml.sax.ContentHandler;
048:
049: import java.net.URI;
050:
051: import java.text.SimpleDateFormat;
052:
053: /**
054: * WsConnection XML export handler
055: * @author <a href="mailto:jourdain@artenum.com">Sebastien Jourdain</a> - <a href="http://www.artenum.com">Artenum</a>
056: */
057: public class WsConnectionExportHandler extends LibresourceExportHandler {
058: private URI uri;
059:
060: public WsConnectionExportHandler(URI userUri) {
061: this .uri = userUri;
062: }
063:
064: public void export(ContentHandler handler, ImportExportLogger logger)
065: throws Exception {
066: KernelService kernelService = (KernelService) Libresource
067: .getService(KernelConstants.SERVICE);
068: LibresourceSynchronizerService synchronizerService = (LibresourceSynchronizerService) Libresource
069: .getService(LibresourceSynchronizerConstants.SERVICE);
070: WsConnectionResourceValue wsConnectionResourceValue = synchronizerService
071: .getWorkspaceConnection(uri);
072:
073: XmlDumpHelper.beginElement("so6", "wsc", XmlDumpHelper
074: .getEmptyAttributesSet(), handler);
075:
076: XmlDumpHelper.outputElementWithContent("wsc", "name",
077: wsConnectionResourceValue.getName(), XmlDumpHelper
078: .getEmptyAttributesSet(), handler);
079: XmlDumpHelper.outputElementWithContent("wsc", "manager",
080: wsConnectionResourceValue.getManager(), XmlDumpHelper
081: .getEmptyAttributesSet(), handler);
082: XmlDumpHelper.outputElementWithContent("wsc", "wsc-path",
083: wsConnectionResourceValue.getWsPath(), XmlDumpHelper
084: .getEmptyAttributesSet(), handler);
085: XmlDumpHelper.outputElementWithContent("wsc", "last-synchro",
086: Libresource.formatDate(wsConnectionResourceValue
087: .getLastSynchro()), XmlDumpHelper
088: .getEmptyAttributesSet(), handler);
089:
090: //Long.toString(wsConnectionResourceValue.getLastSynchro().getTime()), XmlDumpHelper.getEmptyAttributesSet(), handler);
091: XmlDumpHelper.outputElementWithContent("wsc", "last-ticket",
092: Long
093: .toString(wsConnectionResourceValue
094: .getLastTicket()), XmlDumpHelper
095: .getEmptyAttributesSet(), handler);
096: XmlDumpHelper.outputElementWithContent("wsc", "ws-id",
097: wsConnectionResourceValue.getWorkspaceId(),
098: XmlDumpHelper.getEmptyAttributesSet(), handler);
099:
100: XmlDumpHelper.endElement("so6", "wsc", handler);
101: }
102: }
|