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.bugtracker;
034:
035: import org.libresource.Libresource;
036:
037: import org.libresource.bugtracker.interfaces.LibresourceBugTrackerService;
038:
039: import org.libresource.xml.ImportExportLogger;
040: import org.libresource.xml.LibresourceImportHandler;
041:
042: import org.xml.sax.Attributes;
043:
044: import java.net.URI;
045:
046: public class BugTrackerImportHandler extends LibresourceImportHandler {
047: private URI node;
048: private String name;
049: private String description;
050: private String assignee;
051: private boolean enteredInDefinition = false;
052: private StringBuffer tmpContent;
053: private LibresourceBugTrackerService libresourceBugTrackerService;
054:
055: public void handleBeginElement(String name, Attributes attributes,
056: ImportExportLogger logger) throws Exception {
057: if (name.equals("bugtracker:bugtracker")) {
058: enteredInDefinition = true;
059: }
060:
061: if (name.equals("bugtracker:name")) {
062: tmpContent = new StringBuffer();
063: }
064:
065: if (name.equals("bugtracker:description")) {
066: tmpContent = new StringBuffer();
067: }
068:
069: if (name.equals("bugtracker:assignee")) {
070: tmpContent = new StringBuffer();
071: }
072: }
073:
074: public boolean handleEndElement(String name,
075: ImportExportLogger logger) throws Exception {
076: if (name.equals("bugtracker:bugtracker")) {
077: enteredInDefinition = false;
078: libresourceBugTrackerService.createBugTracker(node,
079: this .name, this .description, this .assignee);
080:
081: return true;
082: }
083:
084: if (name.equals("bugtracker:name")) {
085: this .name = tmpContent.toString().trim();
086:
087: return false;
088: }
089:
090: if (name.equals("bugtracker:description")) {
091: this .description = tmpContent.toString().trim();
092:
093: return false;
094: }
095:
096: if (name.equals("bugtracker:assignee")) {
097: this .assignee = tmpContent.toString().trim();
098:
099: return false;
100: }
101:
102: return false;
103: }
104:
105: public void handleContent(String content, ImportExportLogger logger)
106: throws Exception {
107: if (tmpContent != null) {
108: tmpContent.append(content);
109: }
110: }
111:
112: public void init(URI node, ImportExportLogger logger)
113: throws Exception {
114: this .node = node;
115: name = null;
116: description = null;
117: assignee = null;
118: enteredInDefinition = false;
119: tmpContent = null;
120: libresourceBugTrackerService = (LibresourceBugTrackerService) Libresource
121: .getService(BugTrackerConstants.SERVICE);
122: }
123: }
|