KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cowsultants > itracker > ejb > client > util > ImportExportUtilities


1 /*
2  * This software was designed and created by Jason Carroll.
3  * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4  * The author can be reached at jcarroll@cowsultants.com
5  * ITracker website: http://www.cowsultants.com
6  * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it only under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  */

18
19 package cowsultants.itracker.ejb.client.util;
20
21 import java.io.StringReader JavaDoc;
22 import java.util.*;
23
24 import org.xml.sax.InputSource JavaDoc;
25 import org.xml.sax.SAXException JavaDoc;
26 import org.xml.sax.XMLReader JavaDoc;
27 import org.xml.sax.helpers.XMLReaderFactory JavaDoc;
28
29 import cowsultants.itracker.ejb.client.exceptions.*;
30 import cowsultants.itracker.ejb.client.models.*;
31 import cowsultants.itracker.ejb.client.resources.ITrackerResources;
32
33 /**
34   * This class provides functionality needed to import and export issues and their associated
35   * data as XML. This xml provides all the data necessary to import the issues into another
36   * instance of ITracker or some other issue tracking tool.
37   */

38 public class ImportExportUtilities implements ImportExportTags {
39     public static final int IMPORT_STAT_NEW = 0;
40     public static final int IMPORT_STAT_REUSED = 1;
41
42     public static final int IMPORT_STAT_USERS = 0;
43     public static final int IMPORT_STAT_PROJECTS = 1;
44     public static final int IMPORT_STAT_ISSUES = 2;
45     public static final int IMPORT_STAT_STATUSES = 3;
46     public static final int IMPORT_STAT_SEVERITIES = 4;
47     public static final int IMPORT_STAT_RESOLUTIONS = 5;
48     public static final int IMPORT_STAT_FIELDS = 6;
49
50     public ImportExportUtilities() {
51     }
52
53
54     /**
55       * Takes an XML file matching the ITracker import/export DTD and returns an array
56       * of GenericModel objects. The array will contain all of the projects, components
57       * versions, users, custom fields, and issues contained in the XML.
58       * @param xml an xml string to import
59       * @exception ImportExportException thrown if the xml can not be parsed into the appropriate objects
60       */

61     public static GenericModel[] importIssues(String JavaDoc xml) throws ImportExportException {
62         GenericModel[] models = new GenericModel[0];
63
64         try {
65             Logger.logDebug("Starting XML data import.");
66
67             XMLReader JavaDoc reader = XMLReaderFactory.createXMLReader();
68             ImportHandler handler = new ImportHandler();
69             reader.setContentHandler(handler);
70             reader.setErrorHandler(handler);
71             reader.parse(new InputSource JavaDoc(new StringReader JavaDoc(xml)));
72             models = handler.getModels();
73
74             Logger.logDebug("Imported a total of " + models.length + " models.");
75         } catch(Exception JavaDoc e) {
76             Logger.logDebug("Exception.", e);
77             throw new ImportExportException(e.getMessage());
78         }
79
80         return models;
81     }
82
83
84     /**
85       * Takes an array of IssueModels and exports them as XML suitable for import into another
86       * instance of ITracker, or another issue tracking tool.
87       * @param issues an array of IssueModel objects to export
88       * @exception ImportExportException thrown if the array of issues can not be exported
89       */

90     public static String JavaDoc exportIssues(IssueModel[] issues, SystemConfigurationModel config) throws ImportExportException {
91         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
92         HashMap projects = new HashMap();
93         HashMap users = new HashMap();
94         HashSet customFields = new HashSet();
95
96         if(issues == null || issues.length == 0) {
97             throw new ImportExportException("The issue list was null or zero length.");
98         }
99         buf.append("<" + TAG_ISSUES + ">\n");
100         for(int i = 0; i < issues.length; i++) {
101             if(! projects.containsKey(issues[i].getProject().getId().toString())) {
102                 Logger.logDebug("Adding new project " + issues[i].getProject().getId() + " to export.");
103                 projects.put(issues[i].getProject().getId().toString(), issues[i].getProject());
104             }
105
106             if(issues[i].getCreator() != null && ! users.containsKey(issues[i].getCreator().getId().toString())) {
107                 Logger.logDebug("Adding new user " + issues[i].getCreator().getId() + " to export.");
108                 users.put(issues[i].getCreator().getId().toString(), issues[i].getCreator());
109             }
110             if(issues[i].getOwner() != null && ! users.containsKey(issues[i].getOwner().getId().toString())) {
111                 Logger.logDebug("Adding new user " + issues[i].getOwner().getId() + " to export.");
112                 users.put(issues[i].getOwner().getId().toString(), issues[i].getOwner());
113             }
114
115             IssueHistoryModel[] history = issues[i].getHistory();
116             for(int j = 0; j < history.length; j++) {
117                 if(history[j] != null && history[j].getUser() != null && ! users.containsKey(history[j].getUser().getId().toString())) {
118                     Logger.logDebug("Adding new user " + history[j].getUser().getId() + " to export.");
119                     users.put(history[j].getUser().getId().toString(), history[j].getUser());
120                 }
121             }
122
123             IssueAttachmentModel[] attachments = issues[i].getAttachments();
124             for(int j = 0; j < attachments.length; j++) {
125                 if(attachments[j] != null && attachments[j].getUser() != null && ! users.containsKey(attachments[j].getUser().getId().toString())) {
126                     Logger.logDebug("Adding new user " + attachments[j].getUser().getId() + " to export.");
127                     users.put(attachments[j].getUser().getId().toString(), attachments[j].getUser());
128                 }
129             }
130
131             buf.append(exportModel((GenericModel) issues[i]));
132         }
133         buf.append("</" + TAG_ISSUES + ">\n");
134         buf.append("</" + TAG_ROOT + ">\n");
135
136
137         buf.insert(0, "</" + TAG_PROJECTS +">\n");
138         for(Iterator iter = projects.keySet().iterator(); iter.hasNext(); ) {
139             ProjectModel project = (ProjectModel) projects.get((String JavaDoc) iter.next());
140             for(int i = 0; i < project.getOwners().length; i++) {
141                 users.put(project.getOwners()[i].getId().toString(), project.getOwners()[i]);
142             }
143             buf.insert(0, exportModel((GenericModel) project));
144         }
145         buf.insert(0, "<" + TAG_PROJECTS + ">\n");
146
147         buf.insert(0, "</" + TAG_USERS + ">\n");
148         for(Iterator iter = users.keySet().iterator(); iter.hasNext(); ) {
149             buf.insert(0, exportModel((GenericModel) users.get((String JavaDoc) iter.next())));
150         }
151         buf.insert(0, "<" + TAG_USERS + ">\n");
152
153         if(config != null) {
154             buf.insert(0, "</" + TAG_CONFIGURATION +">\n");
155             buf.insert(0, getConfigurationXML(config));
156             buf.insert(0, "<" + TAG_CONFIGURATION + ">\n");
157         }
158
159         buf.insert(0, "<" + TAG_ROOT + ">\n");
160
161         return buf.toString();
162     }
163
164     /**
165       * Returns the appropriate XML block for a given model.
166       * @param model a modle that extends GenericModel
167       * @exception ImportExportException thrown if the given model can not be exported
168       */

169     public static String JavaDoc exportModel(GenericModel model) throws ImportExportException {
170         if(model == null) {
171             throw new ImportExportException("The model to export was null.");
172         } else if(model instanceof IssueModel) {
173             return getIssueXML((IssueModel) model);
174         } else if(model instanceof ProjectModel) {
175             return getProjectXML((ProjectModel) model);
176         } else if(model instanceof UserModel) {
177             return getUserXML((UserModel) model);
178         } else {
179             throw new ImportExportException("This model type can not be exported.");
180         }
181     }
182
183     /**
184       * Generates an XML block that encapsulates an issue for import or export. This
185       * function will not generate the XML for other models needed for a complete import
186       * or export.
187       * @param issue an IssueModel to generate the XML for
188       * @return a String containing the XML for the issue
189       */

190     public static String JavaDoc getIssueXML(IssueModel issue) {
191         if(issue == null) {
192             return "";
193         }
194
195         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
196
197         buf.append("<" + TAG_ISSUE + " " + ATTR_ID + "=\"" + TAG_ISSUE + issue.getId() + "\" " + ATTR_SYSTEMID + "=\"" + issue.getId() + "\">\n");
198         buf.append(" <" + TAG_ISSUE_PROJECT + "><![CDATA[" + TAG_PROJECT + issue.getProjectId() + "]]></" + TAG_ISSUE_PROJECT + ">\n");
199         buf.append(" <" + TAG_ISSUE_DESCRIPTION + "><![CDATA[" + ITrackerResources.escapeUnicodeString(issue.getDescription(), false) + "]]></" + TAG_ISSUE_DESCRIPTION + ">\n");
200         buf.append(" <" + TAG_ISSUE_SEVERITY + ">" + issue.getSeverity() + "</" + TAG_ISSUE_SEVERITY + ">\n");
201         buf.append(" <" + TAG_ISSUE_STATUS + ">" + issue.getStatus() + "</" + TAG_ISSUE_STATUS + ">\n");
202         buf.append(" <" + TAG_ISSUE_RESOLUTION + "><![CDATA[" + ITrackerResources.escapeUnicodeString(issue.getResolution(), false) + "]]></" + TAG_ISSUE_RESOLUTION + ">\n");
203         if(issue.getTargetVersion() != null) {
204             buf.append(" <" + TAG_TARGET_VERSION_ID + ">" + TAG_VERSION + issue.getTargetVersionId() + "</" + TAG_TARGET_VERSION_ID + ">\n");
205         }
206         buf.append(" <" + TAG_CREATE_DATE + ">" + DATE_FORMATTER.format(issue.getCreateDate()) + "</" + TAG_CREATE_DATE + ">\n");
207         buf.append(" <" + TAG_LAST_MODIFIED + ">" + DATE_FORMATTER.format(issue.getLastModifiedDate()) + "</" + TAG_LAST_MODIFIED + ">\n");
208         buf.append(" <" + TAG_CREATOR + ">" + TAG_USER + issue.getCreatorId() + "</" + TAG_CREATOR + ">\n");
209         if(issue.getOwner() != null) {
210             buf.append(" <" + TAG_OWNER + ">" + TAG_USER + issue.getOwnerId() + "</" + TAG_OWNER + ">\n");
211         }
212         if(issue.getComponents().length > 0) {
213             buf.append(" <" + TAG_ISSUE_COMPONENTS + ">\n");
214             for(int i = 0; i < issue.getComponents().length; i++) {
215                 if(issue.getComponents()[i] != null) {
216                     buf.append(" <" + TAG_COMPONENT_ID + ">" + TAG_COMPONENT + issue.getComponents()[i].getId() + "</" + TAG_COMPONENT_ID + ">\n");
217                 }
218             }
219             buf.append(" </" + TAG_ISSUE_COMPONENTS + ">\n");
220         }
221         if(issue.getVersions().length > 0) {
222             buf.append(" <" + TAG_ISSUE_VERSIONS + ">\n");
223             for(int i = 0; i < issue.getVersions().length; i++) {
224                 if(issue.getVersions()[i] != null) {
225                     buf.append(" <" + TAG_VERSION_ID + ">" + TAG_VERSION + issue.getVersions()[i].getId() + "</" + TAG_VERSION_ID + ">\n");
226                 }
227             }
228             buf.append(" </" + TAG_ISSUE_VERSIONS + ">\n");
229         }
230         if(issue.getFields().length > 0) {
231             buf.append(" <" + TAG_ISSUE_FIELDS + ">\n");
232             for(int i = 0; i < issue.getFields().length; i++) {
233                 if(issue.getFields()[i] != null) {
234                     buf.append(" <" + TAG_ISSUE_FIELD + " " + ATTR_ID + "=\"" + TAG_CUSTOM_FIELD + issue.getFields()[i].getCustomFieldId() + "\"><![CDATA[" + issue.getFields()[i].getValue(EXPORT_LOCALE) + "]]></" + TAG_ISSUE_FIELD + ">\n");
235                 }
236             }
237             buf.append(" </" + TAG_ISSUE_FIELDS + ">\n");
238         }
239         if(issue.getAttachments().length > 0) {
240             buf.append(" <" + TAG_ISSUE_ATTACHMENTS + ">\n");
241             for(int i = 0; i < issue.getAttachments().length; i++) {
242                 if(issue.getAttachments()[i] != null) {
243                     buf.append(" <" + TAG_ISSUE_ATTACHMENT + ">");
244                     buf.append(" <" + TAG_ISSUE_ATTACHMENT_DESCRIPTION + "><![CDATA[" + ITrackerResources.escapeUnicodeString(issue.getAttachments()[i].getDescription(), false) + "]]></" + TAG_ISSUE_ATTACHMENT_DESCRIPTION + ">\n");
245                     buf.append(" <" + TAG_ISSUE_ATTACHMENT_FILENAME + "><![CDATA[" + ITrackerResources.escapeUnicodeString(issue.getAttachments()[i].getFileName(), false) + "]]></" + TAG_ISSUE_ATTACHMENT_FILENAME + ">\n");
246                     buf.append(" <" + TAG_ISSUE_ATTACHMENT_ORIGFILE + "><![CDATA[" + ITrackerResources.escapeUnicodeString(issue.getAttachments()[i].getOriginalFileName(), false) + "]]></" + TAG_ISSUE_ATTACHMENT_ORIGFILE + ">\n");
247                     buf.append(" <" + TAG_ISSUE_ATTACHMENT_SIZE + "><![CDATA[" + issue.getAttachments()[i].getSize() + "]]></" + TAG_ISSUE_ATTACHMENT_SIZE + ">\n");
248                     buf.append(" <" + TAG_ISSUE_ATTACHMENT_TYPE + "><![CDATA[" + issue.getAttachments()[i].getType() + "]]></" + TAG_ISSUE_ATTACHMENT_TYPE + ">\n");
249                     buf.append(" <" + TAG_ISSUE_ATTACHMENT_CREATOR + "><![CDATA[" + TAG_USER + issue.getAttachments()[i].getUserId() + "]]></" + TAG_ISSUE_ATTACHMENT_CREATOR + ">\n");
250                     buf.append(" </" + TAG_ISSUE_ATTACHMENT + ">\n");
251                 }
252             }
253             buf.append(" </" + TAG_ISSUE_ATTACHMENTS + ">\n");
254         }
255         if(issue.getHistory().length > 0) {
256             buf.append(" <" + TAG_ISSUE_HISTORY + ">\n");
257             for(int i = 0; i < issue.getHistory().length; i++) {
258                 if(issue.getHistory()[i] != null) {
259                     buf.append(" <" + TAG_HISTORY_ENTRY + " ");
260                     buf.append(ATTR_CREATOR_ID + "=\"" + TAG_USER + issue.getHistory()[i].getUserId() + "\" ");
261                     buf.append(ATTR_DATE + "=\"" + DATE_FORMATTER.format(issue.getHistory()[i].getCreateDate()) + "\" ");
262                     buf.append(ATTR_STATUS + "=\"" + issue.getHistory()[i].getStatus() + "\">");
263                     buf.append("<![CDATA[" + ITrackerResources.escapeUnicodeString(issue.getHistory()[i].getDescription(), false) + "]]>");
264                     buf.append("</" + TAG_HISTORY_ENTRY + ">\n");
265                 }
266             }
267             buf.append(" </" + TAG_ISSUE_HISTORY + ">\n");
268         }
269         buf.append("</" + TAG_ISSUE + ">\n");
270
271         return buf.toString();
272     }
273
274     /**
275       * Generates an XML block that encapsulates a project for import or export. This
276       * function will not generate the XML for other models needed for a complete import
277       * or export.
278       * @param project a ProjectModel to generate the XML for
279       * @return a String containing the XML for the project
280       */

281     public static String JavaDoc getProjectXML(ProjectModel project) {
282         if(project == null) {
283             return "";
284         }
285
286         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
287
288         buf.append("<" + TAG_PROJECT + " " + ATTR_ID + "=\"" + TAG_PROJECT + project.getId() + "\" " + ATTR_SYSTEMID + "=\"" + project.getId() + "\">\n");
289         buf.append(" <" + TAG_PROJECT_NAME + "><![CDATA[" + ITrackerResources.escapeUnicodeString(project.getName(), false) + "]]></" + TAG_PROJECT_NAME + ">\n");
290         buf.append(" <" + TAG_PROJECT_DESCRIPTION + "><![CDATA[" + ITrackerResources.escapeUnicodeString(project.getDescription(), false) + "]]></" + TAG_PROJECT_DESCRIPTION + ">\n");
291         buf.append(" <" + TAG_PROJECT_STATUS + ">" + ProjectUtilities.getStatusName(project.getStatus(), EXPORT_LOCALE) + "</" + TAG_PROJECT_STATUS + ">\n");
292         buf.append(" <" + TAG_PROJECT_OPTIONS + ">" + project.getOptions() + "</" + TAG_PROJECT_OPTIONS + ">\n");
293         if(project.getCustomFields().length > 0) {
294             buf.append(" <" + TAG_PROJECT_FIELDS + ">\n");
295             for(int i = 0; i < project.getCustomFields().length; i++) {
296                 if(project.getCustomFields()[i] != null) {
297                     buf.append(" <" + TAG_PROJECT_FIELD_ID + ">" + TAG_CUSTOM_FIELD + project.getCustomFields()[i].getId() + "</" + TAG_PROJECT_FIELD_ID + ">\n");
298                 }
299             }
300             buf.append(" </" + TAG_PROJECT_FIELDS + ">\n");
301         }
302         if(project.getOwners().length > 0) {
303             buf.append(" <" + TAG_PROJECT_OWNERS + ">\n");
304             for(int i = 0; i < project.getOwners().length; i++) {
305                 if(project.getOwners()[i] != null) {
306                     buf.append(" <" + TAG_PROJECT_OWNER_ID + ">" + TAG_USER + project.getOwners()[i].getId() + "</" + TAG_PROJECT_OWNER_ID + ">\n");
307                 }
308             }
309             buf.append(" </" + TAG_PROJECT_OWNERS + ">\n");
310         }
311         if(project.getComponents().length > 0) {
312             buf.append(" <" + TAG_COMPONENTS + ">\n");
313             for(int i = 0; i < project.getComponents().length; i++) {
314                 if(project.getComponents()[i] != null) {
315                     buf.append(" <" + TAG_COMPONENT + " " + ATTR_ID + "=\"" + TAG_COMPONENT + project.getComponents()[i].getId() + "\" " + ATTR_SYSTEMID + "=\"" + project.getComponents()[i].getId() + "\">\n");
316                     buf.append(" <" + TAG_COMPONENT_NAME + "><![CDATA[" + ITrackerResources.escapeUnicodeString(project.getComponents()[i].getName(), false) + "]]></" + TAG_COMPONENT_NAME + ">\n");
317                     buf.append(" <" + TAG_COMPONENT_DESCRIPTION + "><![CDATA[" + ITrackerResources.escapeUnicodeString(project.getComponents()[i].getDescription(), false) + "]]></" + TAG_COMPONENT_DESCRIPTION + ">\n");
318                     buf.append(" </" + TAG_COMPONENT + ">\n");
319                 }
320             }
321             buf.append(" </" + TAG_COMPONENTS + ">\n");
322         }
323         if(project.getVersions().length > 0) {
324             buf.append(" <" + TAG_VERSIONS + ">\n");
325             for(int i = 0; i < project.getVersions().length; i++) {
326                 if(project.getVersions()[i] != null) {
327                     buf.append(" <" + TAG_VERSION + " " + ATTR_ID + "=\"" + TAG_VERSION + project.getVersions()[i].getId() + "\" " + ATTR_SYSTEMID + "=\"" + project.getVersions()[i].getId() + "\">\n");
328                     buf.append(" <" + TAG_VERSION_NUMBER + "><![CDATA[" + ITrackerResources.escapeUnicodeString(project.getVersions()[i].getNumber(), false) + "]]></" + TAG_VERSION_NUMBER + ">\n");
329                     buf.append(" <" + TAG_VERSION_DESCRIPTION + "><![CDATA[" + ITrackerResources.escapeUnicodeString(project.getVersions()[i].getDescription(), false) + "]]></" + TAG_VERSION_DESCRIPTION + ">\n");
330                     buf.append(" </" + TAG_VERSION + ">\n");
331                 }
332             }
333             buf.append(" </" + TAG_VERSIONS + ">\n");
334         }
335         buf.append("</" + TAG_PROJECT + ">\n");
336
337         return buf.toString();
338     }
339
340     /**
341       * Generates an XML block that encapsulates a user for import or export. This
342       * function will not generate the XML for other models needed for a complete import
343       * or export.
344       * @param user a UserModel to generate the XML for
345       * @return a String containing the XML for the user
346       */

347     public static String JavaDoc getUserXML(UserModel user) {
348         if(user == null) {
349             return "";
350         }
351
352         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
353
354         buf.append("<" + TAG_USER + " " + ATTR_ID + "=\"" + TAG_USER + user.getId() + "\" " + ATTR_SYSTEMID + "=\"" + user.getId() + "\">\n");
355         buf.append(" <" + TAG_LOGIN + "><![CDATA[" + ITrackerResources.escapeUnicodeString(user.getLogin(), false) + "]]></" + TAG_LOGIN + ">\n");
356         buf.append(" <" + TAG_FIRST_NAME + "><![CDATA[" + ITrackerResources.escapeUnicodeString(user.getFirstName(), false) + "]]></" + TAG_FIRST_NAME + ">\n");
357         buf.append(" <" + TAG_LAST_NAME + "><![CDATA[" + ITrackerResources.escapeUnicodeString(user.getLastName(), false) + "]]></" + TAG_LAST_NAME + ">\n");
358         buf.append(" <" + TAG_EMAIL + "><![CDATA[" + ITrackerResources.escapeUnicodeString(user.getEmail(), false) + "]]></" + TAG_EMAIL + ">\n");
359         buf.append(" <" + TAG_USER_STATUS + ">" + UserUtilities.getStatusName(user.getStatus(), EXPORT_LOCALE) + "</" + TAG_USER_STATUS + ">\n");
360         buf.append(" <" + TAG_SUPER_USER + ">" + user.isSuperUser() + "</" + TAG_SUPER_USER + ">\n");
361         buf.append("</" + TAG_USER + ">\n");
362
363         return buf.toString();
364     }
365
366     /**
367       * Generates an XML block that encapsulates the system configuration for import or export.
368       * This function will not generate the XML for other models needed for a complete import
369       * or export.
370       * @param user a SystemConfigurationModel to generate the XML for
371       * @return a String containing the XML for the configuration
372       */

373     public static String JavaDoc getConfigurationXML(SystemConfigurationModel config) {
374         if(config == null) {
375             return "";
376         }
377
378         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
379         buf.append(" <" + TAG_CONFIGURATION_VERSION + "><![CDATA[" + config.getVersion() + "]]></" + TAG_CONFIGURATION_VERSION + ">\n");
380         buf.append(" <" + TAG_CUSTOM_FIELDS + ">\n");
381         for(int i = 0; i < config.getCustomFields().length; i++) {
382             buf.append(" <" + TAG_CUSTOM_FIELD + " " + ATTR_ID + "=\"" + TAG_CUSTOM_FIELD + config.getCustomFields()[i].getId() + "\" " + ATTR_SYSTEMID + "=\"" + config.getCustomFields()[i].getId() + "\">\n");
383             buf.append(" <" + TAG_CUSTOM_FIELD_LABEL + "><![CDATA[" + ITrackerResources.escapeUnicodeString(config.getCustomFields()[i].getName(), false) + "]]></" + TAG_CUSTOM_FIELD_LABEL + ">\n");
384             buf.append(" <" + TAG_CUSTOM_FIELD_TYPE + "><![CDATA[" + config.getCustomFields()[i].getFieldType() + "]]></" + TAG_CUSTOM_FIELD_TYPE + ">\n");
385             buf.append(" <" + TAG_CUSTOM_FIELD_REQUIRED + "><![CDATA[" + config.getCustomFields()[i].isRequired() + "]]></" + TAG_CUSTOM_FIELD_REQUIRED + ">\n");
386             buf.append(" <" + TAG_CUSTOM_FIELD_DATEFORMAT + "><![CDATA[" + ITrackerResources.escapeUnicodeString(config.getCustomFields()[i].getDateFormat(), false) + "]]></" + TAG_CUSTOM_FIELD_DATEFORMAT + ">\n");
387             buf.append(" <" + TAG_CUSTOM_FIELD_SORTOPTIONS + "><![CDATA[" + config.getCustomFields()[i].getSortOptionsByName() + "]]></" + TAG_CUSTOM_FIELD_SORTOPTIONS + ">\n");
388             if(config.getCustomFields()[i].getFieldType() == CustomFieldUtilities.TYPE_LIST) {
389                 CustomFieldValueModel[] options = config.getCustomFields()[i].getOptions();
390                 for(int j = 0; j < options.length; j++) {
391                     buf.append(" <" + TAG_CUSTOM_FIELD_OPTION + " " + ATTR_VALUE + "=\"" + ITrackerResources.escapeUnicodeString(options[j].getValue(), false) + "\"><![CDATA[" + ITrackerResources.escapeUnicodeString(options[j].getName(), false) + "]]></" + TAG_CUSTOM_FIELD_OPTION + ">\n");
392                 }
393             }
394             buf.append(" </" + TAG_CUSTOM_FIELD + ">\n");
395         }
396         buf.append(" </" + TAG_CUSTOM_FIELDS + ">\n");
397         buf.append(" <" + TAG_RESOLUTIONS + ">\n");
398         for(int i = 0; i < config.getResolutions().length; i++) {
399             buf.append(" <" + TAG_RESOLUTION + " " + ATTR_VALUE + "=\"" + config.getResolutions()[i].getValue() + "\" " + ATTR_ORDER + "=\"" + config.getResolutions()[i].getOrder() + "\">");
400             buf.append("<![CDATA[" + ITrackerResources.escapeUnicodeString(config.getResolutions()[i].getName(), false) + "]]>");
401             buf.append("</" + TAG_RESOLUTION + ">\n");
402         }
403         buf.append(" </" + TAG_RESOLUTIONS + ">\n");
404         buf.append(" <" + TAG_SEVERITIES + ">\n");
405         for(int i = 0; i < config.getSeverities().length; i++) {
406             buf.append(" <" + TAG_SEVERITY + " " + ATTR_VALUE + "=\"" + config.getSeverities()[i].getValue() + "\" " + ATTR_ORDER + "=\"" + config.getSeverities()[i].getOrder() + "\">");
407             buf.append("<![CDATA[" + ITrackerResources.escapeUnicodeString(config.getSeverities()[i].getName(), false) + "]]>");
408             buf.append("</" + TAG_SEVERITY + ">\n");
409         }
410         buf.append(" </" + TAG_SEVERITIES+ ">\n");
411         buf.append(" <" + TAG_STATUSES + ">\n");
412         for(int i = 0; i < config.getStatuses().length; i++) {
413             buf.append(" <" + TAG_STATUS + " " + ATTR_VALUE + "=\"" + config.getStatuses()[i].getValue() + "\" " + ATTR_ORDER + "=\"" + config.getStatuses()[i].getOrder() + "\">");
414             buf.append("<![CDATA[" + ITrackerResources.escapeUnicodeString(config.getStatuses()[i].getName(), false) + "]]>");
415             buf.append("</" + TAG_STATUS + ">\n");
416         }
417         buf.append(" </" + TAG_STATUSES + ">\n");
418
419         return buf.toString();
420     }
421 }
422
Popular Tags