Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 40670 Details for
Bug 136219
convert bug parser to use xml and rdf sources
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Bug reports read from xml stream
patchAll.txt (text/plain), 612.28 KB, created by
Robert Elves
on 2006-05-08 19:05:11 EDT
(
hide
)
Description:
Bug reports read from xml stream
Filename:
MIME Type:
Creator:
Robert Elves
Created:
2006-05-08 19:05:11 EDT
Size:
612.28 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.bugzilla.core >Index: src/org/eclipse/mylar/bugzilla/core/BugzillaRemoteContextDelegate.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/bugzilla/core/BugzillaRemoteContextDelegate.java,v >retrieving revision 1.1 >diff -u -r1.1 BugzillaRemoteContextDelegate.java >--- src/org/eclipse/mylar/bugzilla/core/BugzillaRemoteContextDelegate.java 29 Mar 2006 00:55:10 -0000 1.1 >+++ src/org/eclipse/mylar/bugzilla/core/BugzillaRemoteContextDelegate.java 8 May 2006 23:07:23 -0000 >@@ -17,29 +17,29 @@ > > /** > * @author Rob Elves >- * TODO: Find a better spot for this >+ * TODO: Use of this delegate probably isn't necessary anymore > */ > public class BugzillaRemoteContextDelegate implements IRemoteContextDelegate { > >- private Comment comment; >+ private ReportAttachment attachment; > >- public BugzillaRemoteContextDelegate(Comment comment) { >- this.comment = comment; >+ public BugzillaRemoteContextDelegate(ReportAttachment attachment) { >+ this.attachment = attachment; > } > public Date getDate() { >- return comment.getCreated(); >+ return attachment.getDateCreated(); > } > > public String getAuthor() { >- return comment.getAuthor(); >+ return attachment.getAuthor(); > } > > public String getComment() { >- return comment.getText().trim(); >+ return attachment.getDescription(); > } > > public int getId() { >- return comment.getAttachmentId(); >+ return attachment.getId(); > } >- >+ > } >Index: src/org/eclipse/mylar/bugzilla/core/Comment.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/bugzilla/core/Comment.java,v >retrieving revision 1.5 >diff -u -r1.5 Comment.java >--- src/org/eclipse/mylar/bugzilla/core/Comment.java 6 Apr 2006 04:10:47 -0000 1.5 >+++ src/org/eclipse/mylar/bugzilla/core/Comment.java 8 May 2006 23:07:23 -0000 >@@ -12,35 +12,40 @@ > package org.eclipse.mylar.bugzilla.core; > > import java.io.Serializable; >+import java.text.SimpleDateFormat; >+import java.util.Calendar; > import java.util.Date; > >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; >+ > > /** > * A comment posted on a bug. > */ >-public class Comment implements Serializable { >- /** >- * Comment for <code>serialVersionUID</code> >- */ >- private static final long serialVersionUID = 3978422529214199344L; >+public class Comment extends AttributeContainer implements Serializable { >+ >+ private static final long serialVersionUID = -1760372869047050979L; > >+ /** Parser for dates in the report */ >+ public static SimpleDateFormat creation_ts_date_format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); >+ > /** Comment's bug */ >- private final BugReport bug; >+ private final AbstractRepositoryReport bug; > > /** Comment's number */ > private final int number; > >- /** Comment's text */ >- private String text; >- >- /** Comment's author */ >- private final String author; >- >- /** Author's realname, if known */ >- private final String authorName; >+// /** Comment's text */ >+// private String text; >+// >+// /** Comment's author */ >+// private final String author; >+// >+// /** Author's realname, if known */ >+// private final String authorName; > > /** Comment's creation timestamp */ >- private final Date created; >+ private Date created; > > /** Preceding comment */ > private Comment previous; >@@ -48,40 +53,47 @@ > /** Following comment */ > private Comment next; > >- private boolean hasAttachment = false; >- >- private int attachmentId = -1; >- >- private String attachmentDescription = ""; >- >- private boolean obsolete = false; >- >- /** >- * Constructor >- * >- * @param bug >- * The bug that this comment is associated with >- * @param date >- * The date taht this comment was entered on >- * @param author >- * The author of the bug >- * @param authorName >- * The authors real name >- */ >- public Comment(BugReport bug, int number, Date date, String author, String authorName) { >- this.bug = bug; >- this.number = number; >- this.created = date; >- this.author = author; >- this.authorName = authorName; >+// private boolean hasAttachment = false; >+// >+// private int attachmentId = -1; >+// >+// private String attachmentDescription = ""; >+// >+// private boolean obsolete = false; >+ >+ public Comment(AbstractRepositoryReport report, int num) { >+ this.bug = report; >+ this.number = num; > } >+ >+ >+// /** >+// * Constructor >+// * >+// * @param bug >+// * The bug that this comment is associated with >+// * @param date >+// * The date taht this comment was entered on >+// * @param author >+// * The author of the bug >+// * @param authorName >+// * The authors real name >+// * @depricated This use Comment(AbstractRepositoryReport report, int num) instead >+// */ >+// public Comment(AbstractRepositoryReport bug, int number, Date date, String author, String authorName) { >+// this.bug = bug; >+// this.number = number; >+//// this.created = date; >+//// this.author = author; >+//// this.authorName = authorName; >+// } > > /** > * Get the bug that this comment is associated with > * > * @return The bug that this comment is associated with > */ >- public BugReport getBug() { >+ public AbstractRepositoryReport getBug() { > return bug; > } > >@@ -100,6 +112,13 @@ > * @return The comments creation timestamp > */ > public Date getCreated() { >+ if(created == null) { >+ created = Calendar.getInstance().getTime(); >+ try { >+ created = creation_ts_date_format.parse(getAttribute(BugzillaReportElement.CREATION_TS).getValue()); >+ } catch (Exception e) { >+ } >+ } > return created; > } > >@@ -108,17 +127,19 @@ > * > * @return The comments author > */ >- public String getAuthor() { >- return author; >+ public String getAuthor() { >+ return getAttributeValue(BugzillaReportElement.WHO); > } >- >+ > /** > * Get the authors real name >- * >+ * > * @return Returns author's name, or <code>null</code> if not known > */ > public String getAuthorName() { >- return authorName; >+ // TODO: Currently we don't get the real name from the xml. >+ // Need retrieve these names somehow >+ return getAuthor(); > } > > /** >@@ -127,18 +148,18 @@ > * @return The comments text > */ > public String getText() { >- return text; >+ return getAttributeValue(BugzillaReportElement.THETEXT); > } > >- /** >- * Set the comments text >- * >- * @param text >- * The text to set the comment to have >- */ >- public void setText(String text) { >- this.text = text; >- } >+// /** >+// * Set the comments text >+// * >+// * @param text >+// * The text to set the comment to have >+// */ >+// public void setText(String text) { >+// this.text = text; >+// } > > /** > * Get the next comment for the bug >@@ -180,36 +201,38 @@ > this.previous = previous; > } > >- public void setHasAttachment(boolean b) { >- this.hasAttachment = b; >- } >- >- public boolean hasAttachment() { >- return hasAttachment; >- } >- >- public void setAttachmentId(int attachmentID) { >- this.attachmentId = attachmentID; >- } >+// public void setHasAttachment(boolean b) { >+// this.hasAttachment = b; >+// } >+// >+// public boolean hasAttachment() { >+// return hasAttachment; >+// } >+// >+// public void setAttachmentId(int attachmentID) { >+// this.attachmentId = attachmentID; >+// } >+// >+// public int getAttachmentId() { >+// return attachmentId; >+// } >+// >+// public void setAttachmentDescription(String attachmentDescription) { >+// this.attachmentDescription = attachmentDescription; >+// } >+// >+// public String getAttachmentDescription() { >+// return attachmentDescription; >+// } >+// >+// public void setObsolete(boolean obsolete) { >+// this.obsolete = obsolete; >+// } >+// >+// public boolean isObsolete() { >+// return obsolete; >+// } >+// > >- public int getAttachmentId() { >- return attachmentId; >- } >- >- public void setAttachmentDescription(String attachmentDescription) { >- this.attachmentDescription = attachmentDescription; >- } >- >- public String getAttachmentDescription() { >- return attachmentDescription; >- } >- >- public void setObsolete(boolean obsolete) { >- this.obsolete = obsolete; >- } >- >- public boolean isObsolete() { >- return obsolete; >- } > > } >Index: src/org/eclipse/mylar/bugzilla/core/BugReport.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/core/BugReport.java >diff -N src/org/eclipse/mylar/bugzilla/core/BugReport.java >--- src/org/eclipse/mylar/bugzilla/core/BugReport.java 6 Apr 2006 07:00:32 -0000 1.25 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,555 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2003 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.mylar.bugzilla.core; >- >-import java.io.Serializable; >-import java.io.UnsupportedEncodingException; >-import java.nio.charset.Charset; >-import java.util.ArrayList; >-import java.util.Date; >-import java.util.HashMap; >-import java.util.HashSet; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Set; >- >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; >-import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >- >-/** >- * A bug report entered in Bugzilla. >- * >- * @author Mik Kersten (hardening of prototype) >- */ >-public class BugReport implements Serializable, IBugzillaBug { >- >- private static final String ATTR_REPORTER = "Reporter"; >- >- private static final String ATTR_RESOLUTION = "Resolution"; >- >- private static final String ATTR_ASSIGNED_TO = "Assigned To"; >- >- public static final String ATTR_SUMMARY = "Summary"; >- >- public static final String ATTR_STATUS = "Status"; >- >- public static final String ATTR_PRIORITY = "Priority"; >- >- public static final String VAL_STATUS_VERIFIED = "VERIFIED"; >- >- public static final String VAL_STATUS_CLOSED = "CLOSED"; >- >- public static final String VAL_STATUS_RESOLVED = "RESOLVED"; >- >- public static final String VAL_STATUS_NEW = "NEW"; >- >- public static final String KEY_MILESTONE = "target_milestone"; >- >- public static final String ATTRIBUTE_URL = "URL"; >- >- public static final String ATTRIBUTE_PRIORITY = "Priority"; >- >- public static final String ATTRIBUTE_COMPONENT = "Component"; >- >- public static final String ATTRIBUTE_VERSION = "Version"; >- >- public static final String ATTRIBUTE_PLATFORM = "Platform"; >- >- public static final String ATTRIBUTE_MILESTONE = "Target Milestone"; >- >- public static final String ATTRIBUTE_OS = "OS"; >- >- public static final String ATTRIBUTE_SEVERITY = "Severity"; >- >- private static final long serialVersionUID = 3258693199936631348L; >- >- /** Bug id */ >- protected final int id; >- >- /** The bug's server */ >- protected final String repositoryUrl; >- >- /** Description of the bug */ >- protected String description; >- >- /** Creation timestamp */ >- protected Date created; >- >- /** Modification timestamp */ >- protected Date lastModified = null; >- >- /** The bugs valid keywords */ >- protected List<String> validKeywords; >- >- /** The operations that can be done on the bug */ >- protected List<Operation> operations = new ArrayList<Operation>(); >- >- /** Bug attributes (status, resolution, etc.) */ >- protected HashMap<String, Attribute> attributes = new HashMap<String, Attribute>(); >- >-// /** Attachments (Id, Description) **/ >-// protected HashMap<Integer, String> attachements = new HashMap<Integer, String>(); >- >- /** The keys for the bug attributes */ >- protected ArrayList<String> attributeKeys = new ArrayList<String>(); >- >- /** A list of comments */ >- protected ArrayList<Comment> comments = new ArrayList<Comment>(); >- >- /** The value for the new comment to add (text that is saved) */ >- protected String newComment = ""; >- >- /** The new value for the new comment to add (text from submit editor) */ >- protected String newNewComment = ""; >- >- /** CC list */ >- protected HashSet<String> cc = new HashSet<String>(); >- >- /** The operation that was selected to do to the bug */ >- protected Operation selectedOperation = null; >- >- /** Whether or not this bug report is saved offline. */ >- protected boolean savedOffline = false; >- >- protected boolean hasChanges = false; >- >- protected String charset = null; >- >- public BugReport(int id, String server) { >- this.id = id; >- this.repositoryUrl = server; >- } >- >- /** >- * Get the bugs id >- * >- * @return The bugs id >- */ >- public int getId() { >- return id; >- } >- >- public String getRepositoryUrl() { >- return repositoryUrl; >- } >- >- public String getLabel() { >- return id + ": " + getSummary(); >- } >- >- /** >- * Get the bugs description >- * >- * @return The description of the bug >- */ >- public String getDescription() { >- return description; >- } >- >- /** >- * Set the description of the bug >- * >- * @param description >- * The description to set the bug to have >- */ >- public void setDescription(String description) { >- this.description = decodeStringFromCharset(description); >- } >- >- /** >- * Get the summary for the bug >- * >- * @return The bugs summary >- */ >- public String getSummary() { >- if (getAttribute(ATTR_SUMMARY) == null) { >- BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.ERROR, >- "null summary for: " + id, null)); >- return ""; >- } >- return getAttribute(ATTR_SUMMARY).getValue(); >- } >- >- /** >- * Set the summary of the bug >- * >- * @param summary >- * The summary to set the bug to have >- */ >- public void setSummary(String summary) { >- Attribute attribute = new Attribute(ATTR_SUMMARY); >- attribute.setValue(summary); >- addAttribute(attribute); >- } >- >- private String decodeStringFromCharset(String string) { >- String decoded = string; >- if (charset != null && string != null && Charset.availableCharsets().containsKey(charset)) { >- try { >- decoded = new String(string.getBytes(), charset); >- } catch (UnsupportedEncodingException e) { >- // ignore >- } >- } >- return decoded; >- } >- >- /** >- * Get the date that the bug was created >- * >- * @return The bugs creation date >- */ >- public Date getCreated() { >- return created; >- } >- >- /** >- * Set the bugs creation date >- * >- * @param created >- * The date the the bug was created >- */ >- public void setCreated(Date created) { >- this.created = created; >- } >- >- public Attribute getAttribute(String key) { >- return attributes.get(key); >- } >- >- /** >- * Get the list of attributes for this bug >- * >- * @return An <code>ArrayList</code> of the bugs attributes >- */ >- public List<Attribute> getAttributes() { >- // create an array list to store the attributes in >- ArrayList<Attribute> attributeEntries = new ArrayList<Attribute>(attributeKeys.size()); >- >- // go through each of the attribute keys >- for (Iterator<String> it = attributeKeys.iterator(); it.hasNext();) { >- // get the key for the attribute >- String key = it.next(); >- >- // get the attribute and add it to the list >- Attribute attribute = attributes.get(key); >- attributeEntries.add(attribute); >- } >- >- // return the list of attributes for the bug >- return attributeEntries; >- } >- >- public Attribute getAttributeForKnobName(String knobName) { >- for (Iterator<String> it = attributeKeys.iterator(); it.hasNext();) { >- String key = it.next(); >- >- Attribute attribute = attributes.get(key); >- if (attribute != null && attribute.getParameterName() != null >- && attribute.getParameterName().compareTo(knobName) == 0) { >- return attribute; >- } >- } >- >- return null; >- } >- >- /** >- * @param attribute >- * The attribute to add to the bug >- */ >- public void addAttribute(Attribute attribute) { >- if (!attributes.containsKey(attribute.getName())) { >- attributeKeys.add(attribute.getName()); >- } >- >- attribute.setValue(decodeStringFromCharset(attribute.getValue())); >- >- // put the value of the attribute into the map, using its name as the >- // key >- attributes.put(attribute.getName(), attribute); >- } >- >- /** >- * Get the comments posted on the bug >- * >- * @return A list of comments for the bug >- */ >- public ArrayList<Comment> getComments() { >- return comments; >- } >- >- /** >- * Add a comment to the bug >- * >- * @param comment >- * The comment to add to the bug >- */ >- public void addComment(Comment comment) { >- Comment preceding = null; >- if (comments.size() > 0) { >- // if there are some comments, get the last comment and set the next >- // value to be the new comment >- preceding = comments.get(comments.size() - 1); >- preceding.setNext(comment); >- } >- // set the comments previous value to the preceeding one >- comment.setPrevious(preceding); >- >- comment.setText(decodeStringFromCharset(comment.getText())); >- // add the comment to the comment list >- comments.add(comment); >- } >- >- /** >- * Get the person who reported the bug >- * >- * @return The person who reported the bug >- */ >- public String getReporter() { >- return getAttribute(ATTR_REPORTER).getValue(); >- } >- >- /** >- * Get the person to whom this bug is assigned >- * >- * @return The person who is assigned to this bug >- */ >- public String getAssignedTo() { >- return getAttribute(ATTR_ASSIGNED_TO).getValue(); >- } >- >- /** >- * Get the resolution of the bug >- * >- * @return The resolution of the bug >- */ >- public String getResolution() { >- return getAttribute(ATTR_RESOLUTION).getValue(); >- } >- >- /** >- * Get the status of the bug >- * >- * @return The bugs status >- */ >- public String getStatus() { >- return getAttribute(ATTR_STATUS).getValue(); >- } >- >- /** >- * Get the keywords for the bug >- * >- * @return The keywords for the bug >- */ >- public List<String> getKeywords() { >- return validKeywords; >- } >- >- /** >- * Set the keywords for the bug >- * >- * @param keywords >- * The keywords to set the bug to have >- */ >- public void setKeywords(List<String> keywords) { >- this.validKeywords = keywords; >- } >- >- /** >- * Get the set of addresses in the CC list >- * >- * @return A <code>Set</code> of addresses in the CC list >- */ >- public Set<String> getCC() { >- return cc; >- } >- >- /** >- * Add an email to the bugs CC list >- * >- * @param email >- * The email address to add to the CC list >- */ >- public void addCC(String email) { >- cc.add(email); >- } >- >- /** >- * Remove an address from the bugs CC list >- * >- * @param email >- * the address to be removed from the CC list >- * @return <code>true</code> if the email is in the set and it was removed >- */ >- public boolean removeCC(String email) { >- return cc.remove(email); >- } >- >- /** >- * Get the new comment that is to be added to the bug >- * >- * @return The new comment >- */ >- public String getNewComment() { >- return newComment; >- } >- >- /** >- * Set the new comment that will be added to the bug >- * >- * @param newComment >- * The new comment to add to the bug >- */ >- public void setNewComment(String newComment) { >- this.newComment = newComment; >- newNewComment = newComment; >- } >- >- /** >- * @return the new value of the new NewComment. >- */ >- public String getNewNewComment() { >- return newNewComment; >- } >- >- /** >- * Set the new value of the new NewComment >- * >- * @param newNewComment >- * The new value of the new NewComment. >- */ >- public void setNewNewComment(String newNewComment) { >- this.newNewComment = newNewComment; >- } >- >- /** >- * Get all of the operations that can be done to the bug >- * >- * @return The operations that can be done to the bug >- */ >- public List<Operation> getOperations() { >- return operations; >- } >- >- /** >- * Add an operation to the bug >- * >- * @param o >- * The operation to add >- */ >- public void addOperation(Operation o) { >- operations.add(o); >- } >- >- /** >- * Get an operation from the bug based on its display name >- * >- * @param displayText >- * The display text for the operation >- * @return The operation that has the display text >- */ >- public Operation getOperation(String displayText) { >- Iterator<Operation> itr = operations.iterator(); >- while (itr.hasNext()) { >- Operation o = itr.next(); >- String opName = o.getOperationName(); >- opName = opName.replaceAll("</.*>", ""); >- opName = opName.replaceAll("<.*>", ""); >- if (opName.equals(displayText)) >- return o; >- } >- return null; >- } >- >- /** >- * Set the selected operation >- * >- * @param o >- * The selected operation >- */ >- public void setSelectedOperation(Operation o) { >- selectedOperation = o; >- } >- >- /** >- * Get the selected operation >- * >- * @return The selected operation >- */ >- public Operation getSelectedOperation() { >- return selectedOperation; >- } >- >- public boolean isSavedOffline() { >- return savedOffline; >- } >- >- public boolean isLocallyCreated() { >- return false; >- } >- >- public void setOfflineState(boolean newOfflineState) { >- savedOffline = newOfflineState; >- } >- >- public boolean hasChanges() { >- return hasChanges; >- } >- >- public void setHasChanged(boolean b) { >- hasChanges = b; >- } >- >- public boolean isResolved() { >- Attribute status = getAttribute(ATTR_STATUS); >- return status != null && isResolvedStatus(getAttribute(ATTR_STATUS).getValue()); >- } >- >- /** >- * TODO: move? >- */ >- public static boolean isResolvedStatus(String status) { >- if (status != null) { >- return status.equals(VAL_STATUS_RESOLVED) || status.equals(VAL_STATUS_CLOSED) >- || status.equals(VAL_STATUS_VERIFIED); >- } else { >- return false; >- } >- } >- >- public String getCharset() { >- return charset; >- } >- >- public void setCharset(String charset) { >- this.charset = charset; >- } >- >- public Date getLastModified() { >- return lastModified; >- } >- >- public void setLastModified(Date date) { >- this.lastModified = date; >- } >- >- >-// public void addAttachment(int id, String description) { >-// attachements.put(id, description); >-// } >-// >-// public HashMap<Integer, String> getAttachements() { >-// return attachements; >-// } >-} >Index: src/org/eclipse/mylar/bugzilla/core/Attribute.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/core/Attribute.java >diff -N src/org/eclipse/mylar/bugzilla/core/Attribute.java >--- src/org/eclipse/mylar/bugzilla/core/Attribute.java 22 Feb 2006 22:35:20 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,178 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylar.bugzilla.core; >- >-import java.io.Serializable; >-import java.util.LinkedHashMap; >-import java.util.Map; >- >-/** >- * Class representing a Bugzilla report attribute that can be changed on the >- * server. >- */ >-public class Attribute implements Serializable { >- /** Automatically generated serialVersionUID */ >- private static final long serialVersionUID = 3257009873370757424L; >- >- private boolean hidden = false; >- >- /** Attribute name */ >- private String name; >- >- /** Name of the option used when updating the attribute on the server */ >- private String parameterName; >- >- /** Legal values of the attribute */ >- private LinkedHashMap<String, String> optionValues; >- >- /** >- * Attribute's value (input field or selected option; value that is saved or >- * from the server) >- */ >- private String value; >- >- /** Attributes new Value (value chosen in submit editor) */ >- private String newValue; >- >- /** >- * Constructor >- * >- * @param name >- * The name of the attribute >- */ >- public Attribute(String name) { >- // initialize the name and its legal values >- this.name = name; >- optionValues = new LinkedHashMap<String, String>(); >- } >- >- /** >- * Get the attribute's name >- * >- * @return The name of the attribute >- */ >- public String getName() { >- return name; >- } >- >- /** >- * Get name of the option used when updating the attribute on the server >- * >- * @return The name of the option for server updates >- */ >- public String getParameterName() { >- return parameterName; >- } >- >- /** >- * Get whether the attribute can be edited by the used >- * >- * @return <code>true</code> if the attribute can be edited by the user >- */ >- public boolean isEditable() { >- return optionValues.size() > 0; >- } >- >- /** >- * Get the legal values for the option >- * >- * @return The <code>Map</code> of legal values for the option. >- */ >- public Map<String, String> getOptionValues() { >- return optionValues; >- } >- >- /** >- * Get the value of the attribute >- * >- * @return A <code>String</code> of the attributes value >- */ >- public String getValue() { >- return value; >- } >- >- /** >- * Set the value of the attribute >- * >- * @param value >- * The new value of the attribute >- */ >- public void setValue(String value) { >- this.value = value; >- newValue = value; >- } >- >- /** >- * Set the new value of the attribute >- * >- * @param newVal >- * The new value of the attribute >- */ >- public void setNewValue(String newVal) { >- newValue = newVal; >- } >- >- /** >- * Get the new value for the attribute >- * >- * @return The new value >- */ >- public String getNewValue() { >- return newValue; >- } >- >- /** >- * Sets the name of the option used when updating the attribute on the >- * server >- * >- * @param parameterName >- * The name of the option when updating from the server >- */ >- public void setParameterName(String parameterName) { >- this.parameterName = parameterName; >- } >- >- /** >- * Adds an attribute option value >- * >- * @param readableValue >- * The value displayed on the screen >- * @param parameterValue >- * The option value used when sending the form to the server >- */ >- public void addOptionValue(String readableValue, String parameterValue) { >- optionValues.put(readableValue, parameterValue); >- } >- >- /** >- * Determine if the field was hidden or not >- * >- * @return True if the field was hidden >- */ >- public boolean isHidden() { >- return hidden; >- } >- >- /** >- * Set whether the field was hidden in the bug >- * >- * @param b >- * Whether the field was hidden or not >- */ >- public void setHidden(boolean b) { >- hidden = b; >- } >- >- public String toString() { >- return "(" + getName() + " : " + getValue() + ")"; >- } >-} >Index: src/org/eclipse/mylar/bugzilla/core/IBugzillaBug.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/bugzilla/core/IBugzillaBug.java,v >retrieving revision 1.9 >diff -u -r1.9 IBugzillaBug.java >--- src/org/eclipse/mylar/bugzilla/core/IBugzillaBug.java 31 Mar 2006 23:17:42 -0000 1.9 >+++ src/org/eclipse/mylar/bugzilla/core/IBugzillaBug.java 8 May 2006 23:07:23 -0000 >@@ -10,25 +10,23 @@ > *******************************************************************************/ > package org.eclipse.mylar.bugzilla.core; > >-import java.io.Serializable; > import java.util.Date; > import java.util.List; > >- > /** > * Interface representing a Bugzilla bug report. > */ >-public interface IBugzillaBug extends Serializable { >+public interface IBugzillaBug { // extends Serializable > >- /** >- * @return bug's id. >- */ >- public int getId(); >- >- /** >- * @return the server for this bug. >- */ >- public String getRepositoryUrl(); >+ // /** >+ // * @return bug's id. >+ // */ >+ // public int getId(); >+ // >+ // /** >+ // * @return the server for this bug. >+ // */ >+ // public String getRepositoryUrl(); > > /** > * @return the title label for this bug. >@@ -59,38 +57,80 @@ > */ > public void setSummary(String newSummary); > >- /** >- * Get an attribute given its key >- * >- * @return The value of the attribute or <code>null</code> if not present >- */ >- public Attribute getAttribute(String key); >+ // /** >+ // * Get an attribute given its key >+ // * >+ // * @return The value of the attribute or <code>null</code> if not present >+ // */ >+ // public AbstractRepositoryReportAttribute getAttribute(String key); >+ // >+ // /** >+ // * @return the attributes for this bug. >+ // */ >+ // public List<AbstractRepositoryReportAttribute> getAttributes(); >+ >+ // /** >+ // * @return <code>true</code> if this bug report is saved offline. >+ // */ >+ // public boolean isSavedOffline(); >+ >+ // /** >+ // * @return <code>true</code> if this bug was created locally, and does not >+ // * yet exist on a bugzilla server. >+ // */ >+ // public boolean isLocallyCreated(); >+ >+ // /** >+ // * Sets whether or not this bug is saved offline. >+ // * >+ // * @param newOfflineState >+ // * <code>true</code> if this bug is saved offline >+ // */ >+ // public void setOfflineState(boolean newOfflineState); >+ >+ // public boolean hasChanges(); >+ >+ public void addCC(String email); >+ >+ public void addOperation(Operation o); >+ >+ public String getAssignedTo(); >+ >+ public List<String> getCC(); > >- /** >- * @return the attributes for this bug. >- */ >- public List<Attribute> getAttributes(); >+ public List<String> getKeywords(); > >- /** >- * @return <code>true</code> if this bug report is saved offline. >- */ >- public boolean isSavedOffline(); >+ public String getNewComment(); > >- /** >- * @return <code>true</code> if this bug was created locally, and does not >- * yet exist on a bugzilla server. >- */ >- public boolean isLocallyCreated(); >+ // public String getNewNewComment(); >+ public void setNewComment(String newComment); > >- /** >- * Sets whether or not this bug is saved offline. >- * >- * @param newOfflineState >- * <code>true</code> if this bug is saved offline >- */ >+ // public void setNewNewComment(String newNewComment); > public void setOfflineState(boolean newOfflineState); > >- public boolean hasChanges(); >+ //public Operation getOperation(String displayText); >+ >+ public List<Operation> getOperations(); >+ >+ public String getReporter(); >+ >+ public String getResolution(); >+ >+ public void setSelectedOperation(Operation o); >+ >+ public Operation getSelectedOperation(); >+ >+ public String getStatus(); >+ >+ public boolean isResolved(); >+ >+ public void removeCC(String email); >+ >+ // public void setCreated(Date created); >+ public void setKeywords(List<String> keywords); >+ >+ // public void setLastModified(Date date); >+ public String getProduct(); > > /** > * Get the date that the bug was created >Index: src/org/eclipse/mylar/internal/bugzilla/core/internal/SaxConfigurationContentHandler.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/internal/SaxConfigurationContentHandler.java,v >retrieving revision 1.2 >diff -u -r1.2 SaxConfigurationContentHandler.java >--- src/org/eclipse/mylar/internal/bugzilla/core/internal/SaxConfigurationContentHandler.java 25 Apr 2006 01:53:26 -0000 1.2 >+++ src/org/eclipse/mylar/internal/bugzilla/core/internal/SaxConfigurationContentHandler.java 8 May 2006 23:07:24 -0000 >@@ -62,6 +62,8 @@ > private static final String ELEMENT_SEVERITY = "severity"; > > private static final String ELEMENT_PRIORITY = "priority"; >+ >+ private static final String ELEMENT_KEYWORD = "keyword"; > > private static final String ELEMENT_OP_SYS = "op_sys"; > >@@ -108,6 +110,8 @@ > private static final int IN_STATUS_OPEN = 1 << 17; > > private static final int IN_RESOLUTION = 1 << 18; >+ >+ private static final int IN_KEYWORD = 1 << 19; > > private int state = EXPECTING_ROOT; > >@@ -183,6 +187,9 @@ > case IN_RESOLUTION | IN_LI: > configuration.addResolution(String.copyValueOf(ch, start, length)); > break; >+ case IN_KEYWORD | IN_LI: >+ configuration.addKeyword(String.copyValueOf(ch, start, length)); >+ break; > case IN_STATUS_OPEN | IN_LI: > configuration.addOpenStatusValue(String.copyValueOf(ch, start, length)); > break; >@@ -234,6 +241,8 @@ > state = state | IN_STATUS_OPEN; > } else if (localName.equals(ELEMENT_RESOLUTION)) { > state = state | IN_RESOLUTION; >+ } else if (localName.equals(ELEMENT_KEYWORD)) { >+ state = state | IN_KEYWORD; > } > > } >@@ -345,6 +354,8 @@ > state = state & ~IN_STATUS_OPEN; > } else if (localName.equals(ELEMENT_RESOLUTION)) { > state = state & ~IN_RESOLUTION; >+ } else if (localName.equals(ELEMENT_KEYWORD)) { >+ state = state & ~IN_KEYWORD; > } > > } >Index: src/org/eclipse/mylar/internal/bugzilla/core/internal/NewBugParser.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/bugzilla/core/internal/NewBugParser.java >diff -N src/org/eclipse/mylar/internal/bugzilla/core/internal/NewBugParser.java >--- src/org/eclipse/mylar/internal/bugzilla/core/internal/NewBugParser.java 29 Mar 2006 00:34:12 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,427 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylar.internal.bugzilla.core.internal; >- >-import java.io.IOException; >-import java.io.Reader; >-import java.text.ParseException; >- >-import javax.security.auth.login.LoginException; >- >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >-import org.eclipse.mylar.internal.bugzilla.core.internal.HtmlStreamTokenizer.Token; >- >-/** >- * @author Shawn Minto >- * >- * This class parses the valid attribute values for a new bug >- */ >-public class NewBugParser { >- /** Tokenizer used on the stream */ >- private HtmlStreamTokenizer tokenizer; >- >- /** Flag for whether we need to try to get the product or not */ >- private static boolean getProd = false; >- >- public NewBugParser(Reader in) { >- tokenizer = new HtmlStreamTokenizer(in, null); >- } >- >- /** >- * Parse the new bugs valid attributes >- * >- * @param nbm >- * A reference to a NewBugModel where all of the information is >- * stored >- * @throws IOException >- * @throws ParseException >- * @throws LoginException >- */ >- public void parseBugAttributes(NewBugModel nbm, boolean retrieveProducts) throws IOException, ParseException, >- LoginException { >- nbm.attributes.clear(); // clear any attriubtes in bug model from a >- // previous product >- >- NewBugParser.getProd = retrieveProducts; >- >- // create a new bug report and set the parser state to the start state >- ParserState state = ParserState.START; >- String attribute = null; >- >- boolean isTitle = false; >- boolean possibleBadLogin = false; >- boolean isErrorState = false; >- String title = ""; >- // Default error message >- String errorMsg = "Bugzilla could not get the needed bug attribute since your login name or password is incorrect. Please check your settings in the bugzilla preferences."; >- >- for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >- // make sure that bugzilla doesn't want us to login >- if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.TITLE >- && !((HtmlTag) (token.getValue())).isEndTag()) { >- isTitle = true; >- continue; >- } >- >- if (isTitle) { >- // get all of the data in the title tag to compare with >- if (token.getType() != Token.TAG) { >- title += ((StringBuffer) token.getValue()).toString().toLowerCase() + " "; >- continue; >- } else if (token.getType() == Token.TAG >- && ((HtmlTag) token.getValue()).getTagType() == HtmlTag.Type.TITLE >- && ((HtmlTag) token.getValue()).isEndTag()) { >- // check if the title looks like we may have a problem with >- // login >- if (title.indexOf("login") != -1) { >- possibleBadLogin = true; // generic / default msg >- // passed to constructor re: >- // bad login >- } >- if ((title.indexOf("invalid") != -1 && title.indexOf("password") != -1) >- || title.indexOf("check e-mail") != -1 || title.indexOf("error") != -1) { >- possibleBadLogin = true; >- isErrorState = true; // set flag so appropriate msg >- // is provide for the exception >- errorMsg = ""; // error message will be parsed from >- // error page >- } >- >- isTitle = false; >- title = ""; >- } >- continue; >- } >- >- // we have found the start of an attribute name >- if ((state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.TD && "right".equalsIgnoreCase(tag.getAttribute("align"))) { >- // parse the attribute's name >- attribute = parseAttributeName(); >- if(attribute != null && attribute.contains(IBugzillaConstants.INVALID_2201_ATTRIBUTE_IGNORED)) { >- continue; >- } >- if (attribute == null) >- continue; >- state = ParserState.ATT_VALUE; >- continue; >- } >- >- if (tag.getTagType() == HtmlTag.Type.TD && "#ff0000".equalsIgnoreCase(tag.getAttribute("bgcolor"))) { >- state = ParserState.ERROR; >- continue; >- } >- } >- >- // we have found the start of attribute values >- if (state == ParserState.ATT_VALUE && token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.TD) { >- // parse the attribute values >- parseAttributeValue(nbm, attribute); >- >- state = ParserState.ATT_NAME; >- attribute = null; >- continue; >- } >- } >- // page being parsed contains an Error message >- // parse error message so it can be given to the constructor of the >- // exception >- // so an appropriate error message is displayed >- if (state == ParserState.ERROR && isErrorState) { >- // tag should be text token, not a tag >- // get the error message >- if (token.getType() == Token.TEXT) { >- // get string value of next token to add to error messgage >- // unescape the string so any escape sequences parsed appear >- // unescaped in the details pane >- errorMsg += HtmlStreamTokenizer.unescape(((StringBuffer) token.getValue()).toString()) + " "; >- } >- // expect </font> tag to indicate end of error end msg >- // set next state to continue parsing remainder of page >- else if (token.getType() == Token.TAG >- && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.FONT >- && ((HtmlTag) (token.getValue())).isEndTag()) { >- state = ParserState.ATT_NAME; >- } >- continue; >- } >- >- if ((state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.INPUT && tag.getAttribute("type") != null >- && "hidden".equalsIgnoreCase(tag.getAttribute("type").trim())) { >- Attribute a = new Attribute(tag.getAttribute("name")); >- a.setParameterName(tag.getAttribute("name")); >- a.setValue(tag.getAttribute("value")); >- a.setHidden(true); >- nbm.attributes.put(a.getName(), a); >- continue; >- } >- } >- } >- >- if (possibleBadLogin && (nbm.getAttributes() == null || nbm.getAttributes().size() == 0)) { >- throw new LoginException(errorMsg); >- } >- } >- >- /** >- * Parse the case where we have found an attribute name >- * >- * @param tokenizer >- * The tokenizer to use to find the name >- * @return The name of the attribute >- * @throws IOException >- * @throws ParseException >- */ >- private String parseAttributeName() throws IOException, ParseException { >- StringBuffer sb = new StringBuffer(); >- >- parseTableCell(sb); >- HtmlStreamTokenizer.unescape(sb); >- // remove the colon if there is one >- if (sb.length() == 0) >- return null; >- if (sb.charAt(sb.length() - 1) == ':') { >- sb.deleteCharAt(sb.length() - 1); >- } >- return sb.toString(); >- } >- >- /** >- * Reads text into a StringBuffer until it encounters a close table cell tag >- * (</TD>) or start of another cell. The text is appended to the >- * existing value of the buffer. <b>NOTE:</b> Does not handle nested cells! >- * >- * @param tokenizer >- * @param sb >- * @throws IOException >- * @throws ParseException >- */ >- private void parseTableCell(StringBuffer sb) throws IOException, ParseException { >- boolean noWhitespace = false; >- for (HtmlStreamTokenizer.Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer >- .nextToken()) { >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.TD) { >- if (!tag.isEndTag()) { >- tokenizer.pushback(token); >- } >- break; >- } >- noWhitespace = token.getWhitespace().length() == 0; >- } else if (token.getType() == Token.TEXT) { >- // if there was no whitespace between the tag and the >- // preceding text, don't insert whitespace before this text >- // unless it is there in the source >- if (!noWhitespace && token.getWhitespace().length() > 0 && sb.length() > 0) { >- sb.append(' '); >- } >- sb.append((StringBuffer) token.getValue()); >- } >- } >- } >- >- /** >- * Parse the case where we have found attribute values >- * >- * @param nbm >- * The NewBugModel that is to contain information about a new bug >- * @param attributeName >- * The name of the attribute that we are parsing >- * @param tokenizer >- * The tokenizer to use for parsing >- * @throws IOException >- * @throws ParseException >- */ >- private void parseAttributeValue(NewBugModel nbm, String attributeName) throws IOException, ParseException { >- >- HtmlStreamTokenizer.Token token = tokenizer.nextToken(); >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.SELECT && !tag.isEndTag()) { >- String parameterName = tag.getAttribute("name"); >- parseSelect(nbm, attributeName, parameterName); >- } else if (tag.getTagType() == HtmlTag.Type.INPUT && !tag.isEndTag()) { >- parseInput(nbm, attributeName, tag); >- } else if (!tag.isEndTag()) { >- parseAttributeValueCell(nbm, attributeName); >- } >- } else { >- StringBuffer sb = new StringBuffer(); >- if (token.getType() == Token.TEXT) { >- sb.append((StringBuffer) token.getValue()); >- parseAttributeValueCell(nbm, attributeName, sb); >- } >- } >- } >- >- /** >- * Parse the case where the attribute value is just text in a table cell >- * >- * @param attributeName >- * The name of the attribute we are parsing >- * @param tokenizer >- * The tokenizer to use for parsing >- * @throws IOException >- * @throws ParseException >- */ >- private void parseAttributeValueCell(NewBugModel nbm, String attributeName) throws IOException, ParseException { >- StringBuffer sb = new StringBuffer(); >- >- parseAttributeValueCell(nbm, attributeName, sb); >- } >- >- private void parseAttributeValueCell(NewBugModel nbm, String attributeName, StringBuffer sb) throws IOException, >- ParseException { >- >- parseTableCell(sb); >- HtmlStreamTokenizer.unescape(sb); >- >- // if we need the product we will get it >- if (getProd && attributeName.equalsIgnoreCase("product")) { >- nbm.setProduct(sb.toString()); >- } >- } >- >- /** >- * Parse the case where the attribute value is an input >- * >- * @param nbm >- * The new bug model to add information that we get to >- * @param attributeName >- * The name of the attribute that we are parsing >- * @param tag >- * The HTML tag that we are currently on >- * @throws IOException >- */ >- private static void parseInput(NewBugModel nbm, String attributeName, HtmlTag tag) throws IOException { >- >- Attribute a = new Attribute(attributeName); >- a.setParameterName(tag.getAttribute("name")); >- String value = tag.getAttribute("value"); >- if (value == null) >- value = ""; >- >- // if we found the summary, add it to the bug report >- if (attributeName.equalsIgnoreCase("summary")) { >- nbm.setSummary(value); >- } else if (attributeName.equalsIgnoreCase("Attachments")) { >- // do nothing - not a problem after 2.14 >- } else if (attributeName.equalsIgnoreCase("add cc")) { >- // do nothing >- } else if (attributeName.toLowerCase().startsWith("cc")) { >- // do nothing cc's are options not inputs >- } else { >- // otherwise just add the attribute >- a.setValue(value); >- nbm.attributes.put(attributeName, a); >- } >- } >- >- /** >- * Parse the case where the attribute value is an option >- * >- * @param nbm >- * The NewBugModel that we are storing information in >- * @param attributeName >- * The name of the attribute that we are parsing >- * @param parameterName >- * The SELECT tag's name >- * @param tokenizer >- * The tokenizer that we are using for parsing >- * @throws IOException >- * @throws ParseException >- */ >- private void parseSelect(NewBugModel nbm, String attributeName, String parameterName) throws IOException, >- ParseException { >- >- boolean first = false; >- Attribute a = new Attribute(attributeName); >- a.setParameterName(parameterName); >- >- HtmlStreamTokenizer.Token token = tokenizer.nextToken(); >- while (token.getType() != Token.EOF) { >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.SELECT && tag.isEndTag()) >- break; >- if (tag.getTagType() == HtmlTag.Type.OPTION && !tag.isEndTag()) { >- String optionName = tag.getAttribute("value"); >- boolean selected = tag.hasAttribute("selected"); >- StringBuffer optionText = new StringBuffer(); >- for (token = tokenizer.nextToken(); token.getType() == Token.TEXT; token = tokenizer.nextToken()) { >- if (optionText.length() > 0) { >- optionText.append(' '); >- } >- optionText.append((StringBuffer) token.getValue()); >- } >- a.addOptionValue(optionText.toString(), optionName); >- >- if (selected || first) { >- a.setValue(optionText.toString()); >- first = false; >- } >- } else { >- token = tokenizer.nextToken(); >- } >- } else { >- token = tokenizer.nextToken(); >- } >- } >- >- if (!(nbm.attributes).containsKey(attributeName)) { >- (nbm.attributes).put(attributeName, a); >- } >- } >- >- /** >- * Enum class for describing current state of Bugzilla report parser. >- */ >- private static class ParserState { >- /** An instance of the start state */ >- protected static final ParserState START = new ParserState("start"); >- >- /** An instance of the state when the parser found an attribute name */ >- protected static final ParserState ATT_NAME = new ParserState("att_name"); >- >- /** An instance of the state when the parser found an attribute value */ >- protected static final ParserState ATT_VALUE = new ParserState("att_value"); >- >- /** An instance of the state when an error page is found */ >- protected static final ParserState ERROR = new ParserState("error"); >- >- /** State's human-readable name */ >- private String name; >- >- /** >- * Constructor >- * >- * @param description - >- * The states human readable name >- */ >- private ParserState(String description) { >- this.name = description; >- } >- >- @Override >- public String toString() { >- return name; >- } >- } >-} >Index: src/org/eclipse/mylar/internal/bugzilla/core/internal/OfflineReportsFile.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/internal/OfflineReportsFile.java,v >retrieving revision 1.5 >diff -u -r1.5 OfflineReportsFile.java >--- src/org/eclipse/mylar/internal/bugzilla/core/internal/OfflineReportsFile.java 7 Feb 2006 00:54:06 -0000 1.5 >+++ src/org/eclipse/mylar/internal/bugzilla/core/internal/OfflineReportsFile.java 8 May 2006 23:07:24 -0000 >@@ -28,8 +28,7 @@ > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; > import org.eclipse.jface.dialogs.MessageDialog; >-import org.eclipse.mylar.bugzilla.core.BugReport; >-import org.eclipse.mylar.bugzilla.core.IBugzillaBug; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; > import org.eclipse.mylar.internal.bugzilla.core.compare.BugzillaCompareInput; >@@ -40,18 +39,16 @@ > * Class to persist the data for the offline reports list > */ > public class OfflineReportsFile { >- >+ > public enum BugzillaOfflineStatus { > SAVED, SAVED_WITH_OUTGOING_CHANGES, DELETED, SAVED_WITH_INCOMMING_CHANGES, CONFLICT, ERROR > } >- >- >+ > /** The file that the offline reports are written to */ > private File file; > >- /** The directory to where the file is located */ > /** A list of offline reports */ >- private ArrayList<IBugzillaBug> list = new ArrayList<IBugzillaBug>(); >+ private ArrayList<BugzillaReport> list = new ArrayList<BugzillaReport>(); > > /** Sort by bug ID */ > public static final int ID_SORT = 0; >@@ -74,9 +71,10 @@ > * @throws IOException > * Error opening or closing the offline reports file > * @throws ClassNotFoundException >+ * @throws ClassNotFoundException > * Error deserializing objects from the offline reports file > */ >- public OfflineReportsFile(File file) throws IOException { >+ public OfflineReportsFile(File file) throws IOException, ClassNotFoundException { > this.file = file; > if (file.exists()) { > readFile(); >@@ -89,17 +87,17 @@ > * @param entry > * The bug to add > */ >- public BugzillaOfflineStatus add(IBugzillaBug entry, boolean saveChosen) throws CoreException { >- >+ public BugzillaOfflineStatus add(BugzillaReport entry, boolean saveChosen) throws CoreException { >+ > BugzillaOfflineStatus status = BugzillaOfflineStatus.SAVED; >- >+ > try { >- >+ > // check for bug and do a compare > int index = -1; > if ((index = find(entry.getRepositoryUrl(), entry.getId())) >= 0) { >- IBugzillaBug oldBug = list.get(index); >- if (oldBug instanceof BugReport && entry instanceof BugReport && !saveChosen ) { >+ BugzillaReport oldBug = list.get(index); >+ if (oldBug instanceof BugzillaReport && entry instanceof BugzillaReport && !saveChosen) { > CompareConfiguration config = new CompareConfiguration(); > config.setLeftEditable(false); > config.setRightEditable(false); >@@ -110,8 +108,8 @@ > config.setRightImage(PlatformUI.getWorkbench().getSharedImages().getImage( > ISharedImages.IMG_OBJ_ELEMENT)); > final BugzillaCompareInput in = new BugzillaCompareInput(config); >- in.setLeft((BugReport) oldBug); >- in.setRight((BugReport) entry); >+ in.setLeft((BugzillaReport) oldBug); >+ in.setRight((BugzillaReport) entry); > in.setTitle("Bug #" + oldBug.getId()); > > try { >@@ -127,12 +125,12 @@ > } catch (InvocationTargetException x) { > BugzillaPlugin.log(x); > MessageDialog.openError(null, "Compare Failed", x.getTargetException().getMessage()); >- return BugzillaOfflineStatus.ERROR; >+ return BugzillaOfflineStatus.ERROR; > } > > if (in.getCompareResult() == null) { > status = BugzillaOfflineStatus.SAVED; >- } else if (oldBug.hasChanges()) { >+ } else if (oldBug.hasChanges()) { > if (!MessageDialog > .openQuestion( > null, >@@ -140,14 +138,14 @@ > "Local copy of Bug# " > + entry.getId() > + " Has Changes.\nWould you like to override local changes? Note: if you select No, your added comment will be saved with the updated bug, but all other changes will be lost.")) { >- ((BugReport) entry).setNewComment(((BugReport) oldBug).getNewComment()); >- ((BugReport) entry).setHasChanged(true); >- status = BugzillaOfflineStatus.CONFLICT; >+ ((BugzillaReport) entry).setNewComment(((BugzillaReport) oldBug).getNewComment()); >+ ((BugzillaReport) entry).setHasChanged(true); >+ status = BugzillaOfflineStatus.CONFLICT; > } else { >- ((BugReport) entry).setHasChanged(false); >+ ((BugzillaReport) entry).setHasChanged(false); > status = BugzillaOfflineStatus.SAVED; >- } >- } else { >+ } >+ } else { > DiffNode node = (DiffNode) in.getCompareResult(); > IDiffElement[] children = node.getChildren(); > if (children.length != 0) { >@@ -158,7 +156,9 @@ > } > } > } else { >- status = BugzillaOfflineStatus.SAVED; // do we ever get here? >+ status = BugzillaOfflineStatus.SAVED; // do we >+ // ever get >+ // here? > } > } > >@@ -176,10 +176,11 @@ > } > // add the entry to the list and write the file to disk > list.add(entry); >- writeFile(); >+ writeFile(); > } catch (Exception e) { >+ e.printStackTrace(); > IStatus runtimestatus = new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.OK, >- "failed to add of offline report", e); >+ "failed to add offline report", e); > throw new CoreException(runtimestatus); > } > return status; >@@ -213,15 +214,16 @@ > */ > public int find(String repositoryUrl, int id) { > for (int i = 0; i < list.size(); i++) { >- IBugzillaBug currBug = list.get(i); >- if (currBug != null && currBug.getRepositoryUrl() != null >- && (currBug.getRepositoryUrl().equals(repositoryUrl) && currBug.getId() == id) && !currBug.isLocallyCreated()) >+ BugzillaReport currBug = list.get(i); >+ if (currBug != null && currBug.getRepositoryUrl() != null >+ && (currBug.getRepositoryUrl().equals(repositoryUrl) && currBug.getId() == id) >+ && !currBug.isLocallyCreated()) > return i; > } > return -1; > } >- >- public static IBugzillaBug findBug(String repositoryUrl, int bugId) { >+ >+ public static BugzillaReport findBug(String repositoryUrl, int bugId) { > int location = BugzillaPlugin.getDefault().getOfflineReports().find(repositoryUrl, bugId); > if (location != -1) { > return BugzillaPlugin.getDefault().getOfflineReports().elements().get(location); >@@ -234,7 +236,7 @@ > * > * @return The list of offline reports > */ >- public ArrayList<IBugzillaBug> elements() { >+ public ArrayList<BugzillaReport> elements() { > return list; > } > >@@ -252,7 +254,7 @@ > > // write each element in the array list > for (int i = 0; i < list.size(); i++) { >- IBugzillaBug item = list.get(i); >+ BugzillaReport item = list.get(i); > try { > out.writeObject(item); > } catch (IOException e) { >@@ -277,30 +279,40 @@ > * @throws IOException > * Error opening or closing the offline reports file > * @throws ClassNotFoundException >+ * @throws ClassNotFoundException > * Error deserializing objects from the offline reports file > */ >- private void readFile() throws IOException { >- ObjectInputStream in = new ObjectInputStream(new FileInputStream(file)); >+ private void readFile() throws IOException, ClassNotFoundException { >+ >+ ObjectInputStream in = null; >+ try { >+ in = new ObjectInputStream(new FileInputStream(file)); > >- // get the number of offline reports in the file >- int size = in.readInt(); >+ // get the number of offline reports in the file >+ int size = in.readInt(); > >- // get the bug id of the most recently created offline report >- latestNewBugId = in.readInt(); >+ // get the bug id of the most recently created offline report >+ latestNewBugId = in.readInt(); > >- // read in each of the offline reports in the file >- for (int nX = 0; nX < size; nX++) { >- try { >- IBugzillaBug item = (IBugzillaBug) in.readObject(); >+ // read in each of the offline reports in the file >+ for (int nX = 0; nX < size; nX++) { >+ // try { >+ BugzillaReport item = (BugzillaReport) in.readObject(); > // add the offline report to the offlineReports list > list.add(item); >- } catch (ClassNotFoundException e) { >- // ignore this since we can't do anything >- BugzillaPlugin.log(new Status(Status.ERROR, IBugzillaConstants.PLUGIN_ID, Status.ERROR, >- "Unable to read bug object", e)); >+ // } catch (ClassNotFoundException e) { >+ // >+ // // // ignore this since we can't do anything >+ // // BugzillaPlugin.log(new Status(Status.ERROR, >+ // // IBugzillaConstants.PLUGIN_ID, Status.ERROR, >+ // // "Unable to read bug object", e)); >+ // >+ // } > } >+ >+ } finally { >+ in.close(); > } >- in.close(); > } > > /** >@@ -309,7 +321,7 @@ > * @param indicesToRemove > * An array of the indicies of the bugs to be removed > */ >- public void remove(List<IBugzillaBug> sel) { >+ public void remove(List<BugzillaReport> sel) { > list.removeAll(sel); > > // rewrite the file so that the data is persistant >@@ -327,128 +339,129 @@ > } > > } >- // /** >- // * Function to sort the offline reports list >- // * @param sortOrder The way to sort the bugs in the offline reports list >- // */ >- // public void sort(int sortOrder) { >- // IBugzillaBug[] a = list.toArray(new IBugzillaBug[list.size()]); >- // >- // // decide which sorting method to use and sort the offline reports >- // switch(sortOrder) { >- // case ID_SORT: >- // Arrays.sort(a, new SortID()); >- // lastSel = ID_SORT; >- // break; >- // case TYPE_SORT: >- // Arrays.sort(a, new SortType()); >- // lastSel = TYPE_SORT; >- // break; >- // } >- // >- // // remove all of the elements from the list so that we can re-add >- // // them in a sorted order >- // list.clear(); >- // >- // // add the sorted elements to the list and the table >- // for (int j = 0; j < a.length; j++) { >- // add(a[j]); >- // } >- // } >- >- // /** >- // * Inner class to sort by bug id >- // */ >- // private class SortID implements Comparator<IBugzillaBug> { >- // public int compare(IBugzillaBug f1, IBugzillaBug f2) { >- // Integer id1 = f1.getId(); >- // Integer id2 = f2.getId(); >- // >- // if(id1 != null && id2 != null) >- // return id1.compareTo(id2); >- // else if(id1 == null && id2 != null) >- // return -1; >- // else if(id1 != null && id2 == null) >- // return 1; >- // else >- // return 0; >- // } >- // } >- // >- // /** >- // * Inner class to sort by bug type (locally created or from the server) >- // */ >- // private class SortType implements Comparator<IBugzillaBug> { >- // public int compare(IBugzillaBug f1, IBugzillaBug f2) { >- // boolean isLocal1 = f1.isLocallyCreated(); >- // boolean isLocal2 = f2.isLocallyCreated(); >- // >- // if (isLocal1 && !isLocal2) { >- // return -1; >- // } >- // else if (!isLocal1 && isLocal2) { >- // return 1; >- // } >- // >- // // If they are both the same type, sort by ID >- // Integer id1 = f1.getId(); >- // Integer id2 = f2.getId(); >- // >- // if(id1 != null && id2 != null) >- // return id1.compareTo(id2); >- // else if(id1 == null && id2 != null) >- // return -1; >- // else if(id1 != null && id2 == null) >- // return 1; >- // else >- // return 0; >- // } >- // } >- >-// /** >-// * Saves the given report to the offlineReportsFile, or, if it already >-// * exists in the file, updates it. >-// * >-// * @param bug >-// * The bug to add/update. >-// */ >-// public static void saveOffline(IBugzillaBug bug, boolean saveChosen) throws CoreException { >-// OfflineReportsFile file = BugzillaPlugin.getDefault().getOfflineReports(); >-// // If there is already an offline report for this bug, update the file. >-// if (bug.isSavedOffline()) { >-// file.update(); >-// } >-// // If this bug has not been saved offline before, add it to the file. >-// else { >-// int index = -1; >-// // If there is already an offline report with the same id, don't >-// // save this report. >-// if ((index = file.find(bug.getId())) >= 0) { >-// removeReport(getOfflineBugs().get(index)); >-// // MessageDialog.openInformation(null, "Bug's Id is already >-// // used.", "There is already a bug saved offline with an >-// // identical id."); >-// // return; >-// } >-// file.add(bug, saveChosen); >-// bug.setOfflineState(true); >-// // file.sort(OfflineReportsFile.lastSel); >-// } >-// } >- >-// public static List<IBugzillaBug> getOfflineBugs() { >-// OfflineReportsFile file = BugzillaPlugin.getDefault().getOfflineReports(); >-// return file.elements(); >-// } >+// /** >+// * Function to sort the offline reports list >+// * @param sortOrder The way to sort the bugs in the offline reports list >+// */ >+// public void sort(int sortOrder) { >+// IBugzillaBug[] a = list.toArray(new IBugzillaBug[list.size()]); >+// >+// // decide which sorting method to use and sort the offline reports >+// switch(sortOrder) { >+// case ID_SORT: >+// Arrays.sort(a, new SortID()); >+// lastSel = ID_SORT; >+// break; >+// case TYPE_SORT: >+// Arrays.sort(a, new SortType()); >+// lastSel = TYPE_SORT; >+// break; >+// } >+// >+// // remove all of the elements from the list so that we can re-add >+// // them in a sorted order >+// list.clear(); >+// >+// // add the sorted elements to the list and the table >+// for (int j = 0; j < a.length; j++) { >+// add(a[j]); >+// } >+// } >+ >+// /** >+// * Inner class to sort by bug id >+// */ >+// private class SortID implements Comparator<IBugzillaBug> { >+// public int compare(IBugzillaBug f1, IBugzillaBug f2) { >+// Integer id1 = f1.getId(); >+// Integer id2 = f2.getId(); >+// >+// if(id1 != null && id2 != null) >+// return id1.compareTo(id2); >+// else if(id1 == null && id2 != null) >+// return -1; >+// else if(id1 != null && id2 == null) >+// return 1; >+// else >+// return 0; >+// } >+// } >+// >+// /** >+// * Inner class to sort by bug type (locally created or from the server) >+// */ >+// private class SortType implements Comparator<IBugzillaBug> { >+// public int compare(IBugzillaBug f1, IBugzillaBug f2) { >+// boolean isLocal1 = f1.isLocallyCreated(); >+// boolean isLocal2 = f2.isLocallyCreated(); >+// >+// if (isLocal1 && !isLocal2) { >+// return -1; >+// } >+// else if (!isLocal1 && isLocal2) { >+// return 1; >+// } >+// >+// // If they are both the same type, sort by ID >+// Integer id1 = f1.getId(); >+// Integer id2 = f2.getId(); >+// >+// if(id1 != null && id2 != null) >+// return id1.compareTo(id2); >+// else if(id1 == null && id2 != null) >+// return -1; >+// else if(id1 != null && id2 == null) >+// return 1; >+// else >+// return 0; >+// } >+// } >+ >+// /** >+// * Saves the given report to the offlineReportsFile, or, if it already >+// * exists in the file, updates it. >+// * >+// * @param bug >+// * The bug to add/update. >+// */ >+// public static void saveOffline(IBugzillaBug bug, boolean saveChosen) throws >+// CoreException { >+// OfflineReportsFile file = BugzillaPlugin.getDefault().getOfflineReports(); >+// // If there is already an offline report for this bug, update the file. >+// if (bug.isSavedOffline()) { >+// file.update(); >+// } >+// // If this bug has not been saved offline before, add it to the file. >+// else { >+// int index = -1; >+// // If there is already an offline report with the same id, don't >+// // save this report. >+// if ((index = file.find(bug.getId())) >= 0) { >+// removeReport(getOfflineBugs().get(index)); >+// // MessageDialog.openInformation(null, "Bug's Id is already >+// // used.", "There is already a bug saved offline with an >+// // identical id."); >+// // return; >+// } >+// file.add(bug, saveChosen); >+// bug.setOfflineState(true); >+// // file.sort(OfflineReportsFile.lastSel); >+// } >+// } >+ >+// public static List<IBugzillaBug> getOfflineBugs() { >+// OfflineReportsFile file = BugzillaPlugin.getDefault().getOfflineReports(); >+// return file.elements(); >+// } > // >-// /** >-// * Removes the given report from the offlineReportsFile. >-// * >-// * @param bug >-// * The report to remove. >-// */ >-// public static void removeReport(IBugzillaBug bug) { >-// ArrayList<IBugzillaBug> bugList = new ArrayList<IBugzillaBug>(); >-// bugList.add(bug); >-// BugzillaPlugin.getDefault().getOfflineReports().remove(bugList); >-// } >+// /** >+// * Removes the given report from the offlineReportsFile. >+// * >+// * @param bug >+// * The report to remove. >+// */ >+// public static void removeReport(IBugzillaBug bug) { >+// ArrayList<IBugzillaBug> bugList = new ArrayList<IBugzillaBug>(); >+// bugList.add(bug); >+// BugzillaPlugin.getDefault().getOfflineReports().remove(bugList); >+// } >Index: src/org/eclipse/mylar/internal/bugzilla/core/internal/ServerConfigurationFactory.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/bugzilla/core/internal/ServerConfigurationFactory.java >diff -N src/org/eclipse/mylar/internal/bugzilla/core/internal/ServerConfigurationFactory.java >--- src/org/eclipse/mylar/internal/bugzilla/core/internal/ServerConfigurationFactory.java 27 Apr 2006 00:24:00 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,89 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylar.internal.bugzilla.core.internal; >- >-import java.io.BufferedReader; >-import java.io.IOException; >-import java.io.InputStreamReader; >-import java.io.StringReader; >-import java.net.URL; >-import java.net.URLConnection; >- >-import org.eclipse.mylar.internal.core.util.MylarStatusHandler; >-import org.xml.sax.ErrorHandler; >-import org.xml.sax.InputSource; >-import org.xml.sax.SAXException; >-import org.xml.sax.SAXParseException; >-import org.xml.sax.XMLReader; >-import org.xml.sax.helpers.XMLReaderFactory; >- >-/** >- * Reads bugzilla product configuration from config.cgi on server in RDF format. >- * >- * @author Rob Elves >- */ >-public class ServerConfigurationFactory { >- >- private static final String CONFIG_RDF_URL = "/config.cgi?ctype=rdf"; >- >- private static ServerConfigurationFactory instance; >- >- private ServerConfigurationFactory() { >- // no initial setup needed >- } >- >- public static ServerConfigurationFactory getInstance() { >- if (instance == null) { >- instance = new ServerConfigurationFactory(); >- } >- return instance; >- } >- >- public RepositoryConfiguration getConfiguration(String server) throws IOException { >- URL serverURL = new URL(server + CONFIG_RDF_URL); >- URLConnection c = serverURL.openConnection(); >- BufferedReader in = new BufferedReader(new InputStreamReader(c.getInputStream())); >- >- SaxConfigurationContentHandler contentHandler = new SaxConfigurationContentHandler(); >- >- try { >- StringBuffer result = XmlCleaner.clean(in); >- StringReader strReader = new StringReader(result.toString()); >- XMLReader reader = XMLReaderFactory.createXMLReader(); >- reader.setErrorHandler(new SaxErrorHandler()); >- reader.setContentHandler(contentHandler); >- reader.parse(new InputSource(strReader)); >- } catch (SAXException e) { >- throw new IOException("Unable to read server configuration."); >- } >- return contentHandler.getConfiguration(); >- >- } >- >- class SaxErrorHandler implements ErrorHandler { >- >- public void error(SAXParseException exception) throws SAXException { >- MylarStatusHandler.fail(exception, "ServerConfigurationFactory: " + exception.getLocalizedMessage(), false); >- } >- >- public void fatalError(SAXParseException exception) throws SAXException { >- MylarStatusHandler.fail(exception, "ServerConfigurationFactory: " + exception.getLocalizedMessage(), false); >- >- } >- >- public void warning(SAXParseException exception) throws SAXException { >- // ignore >- } >- >- } >- >-} >Index: src/org/eclipse/mylar/internal/bugzilla/core/internal/RepositoryConfiguration.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/internal/RepositoryConfiguration.java,v >retrieving revision 1.2 >diff -u -r1.2 RepositoryConfiguration.java >--- src/org/eclipse/mylar/internal/bugzilla/core/internal/RepositoryConfiguration.java 25 Apr 2006 01:53:26 -0000 1.2 >+++ src/org/eclipse/mylar/internal/bugzilla/core/internal/RepositoryConfiguration.java 8 May 2006 23:07:24 -0000 >@@ -43,6 +43,8 @@ > > private List<String> resolutionValues = new ArrayList<String>(); > >+ private List<String> keywords = new ArrayList<String>(); >+ > // master lists > > private List<String> versions = new ArrayList<String>(); >@@ -88,7 +90,7 @@ > */ > public List<String> getProducts() { > ArrayList<String> productList = new ArrayList<String>(products.keySet()); >- Collections.sort(productList); >+ Collections.sort(productList); > return productList; > } > >@@ -214,13 +216,20 @@ > // } > // } > >+ public void addKeyword(String keyword) { >+ keywords.add(keyword); >+ } >+ >+ public List<String> getKeywords() { >+ return keywords; >+ } >+ > public void addPlatform(String platform) { > platforms.add(platform); > } > > public void addPriority(String priority) { > priorities.add(priority); >- > } > > public void addSeverity(String severity) { >@@ -323,4 +332,40 @@ > return versions; > } > >+ /* >+ * Intermediate step until configuration is made generic. >+ */ >+ >+ public List<String> getOptionValues(BugzillaReportElement element, String product) { >+ switch (element) { >+ case PRODUCT: >+ return getProducts(); >+ case TARGET_MILESTONE: >+ // return getTargetMilestones(); >+ return getTargetMilestones(product); >+ case BUG_STATUS: >+ return getStatusValues(); >+ case VERSION: >+ // return getVersions(); >+ return getVersions(product); >+ case COMPONENT: >+ // return getComponents(); >+ return getComponents(product); >+ case REP_PLATFORM: >+ return getPlatforms(); >+ case OP_SYS: >+ return getOSs(); >+ case PRIORITY: >+ return getPriorities(); >+ case BUG_SEVERITY: >+ return getSeverities(); >+ case KEYWORDS: >+ return getKeywords(); >+ case RESOLUTION: >+ return getResolutions(); >+ default: >+ return new ArrayList<String>(); >+ } >+ } >+ > } >Index: src/org/eclipse/mylar/internal/bugzilla/core/internal/Favorite.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/internal/Favorite.java,v >retrieving revision 1.2 >diff -u -r1.2 Favorite.java >--- src/org/eclipse/mylar/internal/bugzilla/core/internal/Favorite.java 7 Feb 2006 00:54:06 -0000 1.2 >+++ src/org/eclipse/mylar/internal/bugzilla/core/internal/Favorite.java 8 May 2006 23:07:24 -0000 >@@ -14,7 +14,7 @@ > import java.util.Date; > import java.util.Map; > >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.internal.bugzilla.core.search.BugzillaSearchResultCollector; > > /** >@@ -48,7 +48,7 @@ > * @param bug > * The bug this favorite represents. > */ >- public Favorite(BugReport bug) { >+ public Favorite(BugzillaReport bug) { > this(bug.getRepositoryUrl(), bug.getId(), bug.getSummary(), "", BugzillaSearchResultCollector.getAttributeMap(bug)); > } > >Index: src/org/eclipse/mylar/internal/bugzilla/core/internal/BugParser.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/bugzilla/core/internal/BugParser.java >diff -N src/org/eclipse/mylar/internal/bugzilla/core/internal/BugParser.java >--- src/org/eclipse/mylar/internal/bugzilla/core/internal/BugParser.java 8 Apr 2006 00:52:12 -0000 1.9 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,1107 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2003 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.mylar.internal.bugzilla.core.internal; >- >-import java.io.BufferedReader; >-import java.io.IOException; >-import java.io.InputStreamReader; >-import java.io.Reader; >-import java.net.URL; >-import java.net.URLConnection; >-import java.net.URLEncoder; >-import java.nio.charset.Charset; >-import java.text.ParseException; >-import java.text.SimpleDateFormat; >-import java.util.Calendar; >-import java.util.Date; >-import java.util.Iterator; >-import java.util.List; >- >-import javax.security.auth.login.LoginException; >- >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.bugzilla.core.BugReport; >-import org.eclipse.mylar.bugzilla.core.Comment; >-import org.eclipse.mylar.bugzilla.core.Operation; >-import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; >-import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >-import org.eclipse.mylar.internal.bugzilla.core.internal.HtmlStreamTokenizer.Token; >- >-/** >- * @author Shawn Minto >- * @author Mik Kersten (hardening of prototype) >- * @author Rob Elves (attachments) This class parses bugs so that they can be >- * displayed using the bug editor >- */ >-public class BugParser { >- >- private static final String VALUE_ATTACHMENT_OBSOLETE = "bz_obsolete"; >- >- private static final String ATTRIBUTE_CLASS = "class"; >- >- private static final String TAG_SPAN = "span"; >- >- private static final String ATTRIBUTE_ID_TITLE = "title"; >- >- private static final String ATTRIBUTE_ID_HREF = "href"; >- >- private static final String ATTACHMENT_CGI_ID = "attachment.cgi?id="; >- >- private static final String KEY_BUG_NUM = "Bug#"; >- >- private static final String KEY_RESOLUTION = "resolution"; >- >- private static final String KEY_VALUE = "value"; >- >- private static final String KEY_NAME = "name"; >- >- private static final String ATTR_CHARSET = "charset"; >- >- /** Parser for dates in the report */ >- private static SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); >- >- private static final String keywordsUrl = "describekeywords.cgi"; >- >- /** >- * Parse the case where we have found an attribute name >- * >- * @param in >- * The input stream for the bug >- * @return The name of the attribute that we are parsing >- * @throws IOException >- */ >- private static String parseAttributeName(HtmlStreamTokenizer tokenizer) throws IOException, ParseException { >- StringBuffer sb = new StringBuffer(); >- >- parseTableCell(tokenizer, sb); >- HtmlStreamTokenizer.unescape(sb); >- // remove the colon if there is one >- if (sb.length() > 0 && sb.charAt(sb.length() - 1) == ':') { >- sb.deleteCharAt(sb.length() - 1); >- } >- return sb.toString(); >- } >- >- /** >- * Parse the case where we have found attribute values >- * >- * @param in >- * The input stream of the bug >- * @param bug >- * The bug report for the current bug >- * @param attribute >- * The name of the attribute >- * @throws IOException >- */ >- private static void parseAttributeValue(BugReport bug, String originalAttributeName, HtmlStreamTokenizer tokenizer, >- String serverUrl, String userName, String password) throws IOException, ParseException { >- >- // NOTE: special rule to deal with change in 2.20.1 >- String attributeName = originalAttributeName; >- if (attributeName.endsWith(KEY_BUG_NUM) && attributeName.length() > KEY_BUG_NUM.length()) { >- attributeName = originalAttributeName.substring(attributeName.length() - KEY_BUG_NUM.length(), >- attributeName.length()); >- } >- >- Token token = tokenizer.nextToken(); >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- >- // make sure that we are on a tag that we care about, not a label >- // fix added so that we can parse the mozilla bug pages >- if (tag.getTagType() == HtmlTag.Type.LABEL) { >- token = tokenizer.nextToken(); >- if (token.getType() == Token.TAG) >- tag = (HtmlTag) token.getValue(); >- else { >- StringBuffer sb = new StringBuffer(); >- if (token.getType() == Token.TEXT) { >- sb.append((StringBuffer) token.getValue()); >- parseAttributeValueCell(bug, attributeName, tokenizer, sb); >- } >- } >- } >- >- if (tag.getTagType() == HtmlTag.Type.SELECT && !tag.isEndTag()) { >- String parameterName = tag.getAttribute(KEY_NAME); >- parseSelect(bug, attributeName, parameterName, tokenizer); >- } else if (tag.getTagType() == HtmlTag.Type.INPUT && !tag.isEndTag()) { >- parseInput(bug, attributeName, tag, serverUrl, userName, password); >- } else if (!tag.isEndTag() || attributeName.equalsIgnoreCase(KEY_RESOLUTION)) { >- if (tag.isEndTag() && attributeName.equalsIgnoreCase(KEY_RESOLUTION)) { >- Attribute a = new Attribute(attributeName); >- a.setValue(""); >- bug.addAttribute(a); >- } >- parseAttributeValueCell(bug, attributeName, tokenizer); >- } >- } else { >- StringBuffer sb = new StringBuffer(); >- if (token.getType() == Token.TEXT) { >- sb.append((StringBuffer) token.getValue()); >- parseAttributeValueCell(bug, attributeName, tokenizer, sb); >- } >- } >- } >- >- /** >- * Parse the case where the attribute value is just text in a table cell >- * >- * @param in >- * The input stream of the bug >- * @param bug >- * The bug report for the current bug >- * @param attributeName >- * The name of the attribute that we are parsing >- * @throws IOException >- */ >- private static void parseAttributeValueCell(BugReport bug, String attributeName, HtmlStreamTokenizer tokenizer) >- throws IOException, ParseException { >- StringBuffer sb = new StringBuffer(); >- parseAttributeValueCell(bug, attributeName, tokenizer, sb); >- } >- >- private static void parseAttributeValueCell(BugReport bug, String attributeName, HtmlStreamTokenizer tokenizer, >- StringBuffer sb) throws IOException, ParseException { >- >- parseTableCell(tokenizer, sb); >- HtmlStreamTokenizer.unescape(sb); >- >- // create a new attribute and set its value to the value that we >- // retrieved >- Attribute a = new Attribute(attributeName); >- a.setValue(sb.toString()); >- >- // if we found an attachment attribute, forget about it, else add the >- // attribute to the bug report >- if (attributeName.toLowerCase().startsWith("attachments")) { >- // do nothing >- } else { >- if (attributeName.equals(KEY_BUG_NUM)) >- a.setValue(a.getValue().replaceFirst("alias:", "")); >- bug.addAttribute(a); >- } >- } >- >- /** >- * Reads text into a StringBuffer until it encounters a close table cell tag >- * (</TD>) or start of another cell. The text is appended to the >- * existing value of the buffer. <b>NOTE:</b> Does not handle nested cells! >- * >- * @param tokenizer >- * @param sb >- * @throws IOException >- * @throws ParseException >- */ >- private static void parseTableCell(HtmlStreamTokenizer tokenizer, StringBuffer sb) throws IOException, >- ParseException { >- boolean noWhitespace = false; >- for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.TD) { >- if (!tag.isEndTag()) { >- tokenizer.pushback(token); >- } >- break; >- } >- noWhitespace = token.getWhitespace().length() == 0; >- } else if (token.getType() == Token.TEXT) { >- // if there was no whitespace between the tag and the >- // preceding text, don't insert whitespace before this text >- // unless it is there in the source >- if (!noWhitespace && token.getWhitespace().length() > 0 && sb.length() > 0) { >- sb.append(' '); >- } >- sb.append((StringBuffer) token.getValue()); >- } >- } >- } >- >- /** >- * Parse the case where the attribute value is an option >- * >- * @param in >- * The input stream for the bug >- * @param bug >- * The bug report for the current bug >- * @param attribute >- * The name of the attribute that we are parsing >- * @param parameterName >- * the SELECT tag's name >- * @throws IOException >- */ >- private static void parseSelect(BugReport bug, String attributeName, String parameterName, >- HtmlStreamTokenizer tokenizer) throws IOException, ParseException { >- >- boolean first = false; >- Attribute a = new Attribute(attributeName); >- a.setParameterName(parameterName); >- >- Token token = tokenizer.nextToken(); >- while (token.getType() != Token.EOF) { >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.SELECT && tag.isEndTag()) >- break; >- if (tag.getTagType() == HtmlTag.Type.OPTION && !tag.isEndTag()) { >- String optionName = tag.getAttribute(KEY_VALUE); >- boolean selected = tag.hasAttribute("selected"); >- StringBuffer optionText = new StringBuffer(); >- for (token = tokenizer.nextToken(); token.getType() == Token.TEXT; token = tokenizer.nextToken()) { >- if (optionText.length() > 0) { >- optionText.append(' '); >- } >- optionText.append((StringBuffer) token.getValue()); >- } >- a.addOptionValue(optionText.toString(), optionName); >- if (selected || first) { >- a.setValue(optionText.toString()); >- first = false; >- } >- } else { >- token = tokenizer.nextToken(); >- } >- } else { >- token = tokenizer.nextToken(); >- } >- } >- >- // if we parsed the cc field add the e-mails to the bug report else add >- // the attribute to the bug report >- if (attributeName.toLowerCase().startsWith("cc")) { >- for (Iterator<String> it = a.getOptionValues().keySet().iterator(); it.hasNext();) { >- String email = it.next(); >- bug.addCC(HtmlStreamTokenizer.unescape(email)); >- } >- } else { >- bug.addAttribute(a); >- } >- } >- >- /** >- * Parse the case where the attribute value is an input >- * >- * @param bug >- * The bug report for the current bug >- * @param attributeName >- * The name of the attribute >- * @param tag >- * The INPUT tag >- * @throws IOException >- */ >- private static void parseInput(BugReport bug, String attributeName, HtmlTag tag, String serverUrl, String userName, >- String password) throws IOException { >- >- Attribute a = new Attribute(attributeName); >- a.setParameterName(tag.getAttribute(KEY_NAME)); >- String name = tag.getAttribute(KEY_NAME); >- String value = tag.getAttribute(KEY_VALUE); >- if (value == null) >- value = ""; >- >- // if we found the summary, add it to the bug report >- if (name.equalsIgnoreCase("short_desc")) { >- bug.setSummary(value); >- } else if (name.equalsIgnoreCase("bug_file_loc")) { >- a.setValue(value); >- bug.addAttribute(a); >- } else if (name.equalsIgnoreCase("newcc")) { >- a.setValue(value); >- bug.addAttribute(a); >- } else { >- // otherwise just add the attribute >- a.setValue(value); >- bug.addAttribute(a); >- >- if (attributeName.equalsIgnoreCase("keywords") && serverUrl != null) { >- >- BufferedReader input = null; >- try { >- >- String urlText = ""; >- >- // if we have a user name, may as well log in just in case >- // it is required >- if (userName != null && !userName.equals("") && password != null && !password.equals("")) { >- /* >- * The UnsupportedEncodingException exception for >- * URLEncoder.encode() should not be thrown, since every >- * implementation of the Java platform is required to >- * support the standard charset "UTF-8" >- */ >- urlText += "?GoAheadAndLogIn=1&Bugzilla_login=" + URLEncoder.encode(userName, "UTF-8") >- + "&Bugzilla_password=" + URLEncoder.encode(password, "UTF-8"); >- } >- >- // connect to the bugzilla server to get the keyword list >- URL url = new URL(serverUrl + "/" + keywordsUrl + urlText); >- URLConnection urlConnection = BugzillaPlugin.getDefault().getUrlConnection(url); >- input = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); >- >- // parse the valid keywords and add them to the bug >- List<String> keywords = new KeywordParser(input).getKeywords(); >- bug.setKeywords(keywords); >- >- } catch (Exception e) { >- // throw an exception if there is a problem reading the bug >- // from the server >- throw new IOException("Exception while fetching the list of keywords from the server: " >- + e.getMessage()); >- } finally { >- try { >- if (input != null) >- input.close(); >- } catch (IOException e) { >- BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.ERROR, >- "Problem closing the stream", e)); >- } >- } >- } >- } >- } >- >- /** >- * Parse the case where we are dealing with the description >- * >- * @param bug >- * The bug report for the bug >- * @throws IOException >- */ >- private static void parseDescription(BugReport bug, HtmlStreamTokenizer tokenizer) throws IOException, >- ParseException { >- >- StringBuffer sb = new StringBuffer(); >- for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (sb.length() > 0) { >- sb.append(token.getWhitespace()); >- } >- if (tag.getTagType() == HtmlTag.Type.PRE && tag.isEndTag()) >- break; >- } else if (token.getType() == Token.TEXT) { >- if (sb.length() > 0) { >- sb.append(token.getWhitespace()); >- } >- sb.append((StringBuffer) token.getValue()); >- } >- } >- >- // set the bug to have the description we retrieved >- String text = HtmlStreamTokenizer.unescape(sb).toString(); >- bug.setDescription(text); >- } >- >- // /** >- // * parses the description of an attachment on the report >- // */ >- // private static String parseAttachementDescription(HtmlStreamTokenizer >- // tokenizer) throws IOException, >- // ParseException { >- // >- // StringBuffer sb = new StringBuffer(); >- // for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; >- // token = tokenizer.nextToken()) { >- // if (token.getType() == Token.TAG) { >- // HtmlTag tag = (HtmlTag) token.getValue(); >- // if (tag.getTagType() == HtmlTag.Type.A && tag.isEndTag()) >- // break; >- // } else if (token.getType() == Token.TEXT) { >- // if (sb.length() > 0) { >- // sb.append(token.getWhitespace()); >- // } >- // sb.append((StringBuffer) token.getValue()); >- // } >- // } >- // >- // // set the bug to have the description we retrieved >- // String text = HtmlStreamTokenizer.unescape(sb).toString(); >- // return text; >- // } >- >- /** >- * Parse the case where we have found the start of a comment >- * >- * @param in >- * The input stream of the bug >- * @param bug >- * The bug report for the current bug >- * @return The comment that we have created with the information >- * @throws IOException >- * @throws ParseException >- */ >- private static Comment parseCommentHead(BugReport bug, HtmlStreamTokenizer tokenizer) throws IOException, >- ParseException { >- int number = 0; >- Date date = null; >- String author = null; >- String authorName = null; >- >- // get the comment's number >- for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.A) { >- String href = tag.getAttribute(ATTRIBUTE_ID_HREF); >- if (href != null) { >- int index = href.toLowerCase().indexOf("#c"); >- if (index == -1) >- continue; >- token = tokenizer.nextToken(); >- number = Integer.parseInt(((StringBuffer) token.getValue()).toString().substring(1)); >- break; >- } >- } >- } >- } >- >- for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.A) { >- String href = tag.getAttribute(ATTRIBUTE_ID_HREF); >- if (href != null) { >- int index = href.toLowerCase().indexOf("mailto"); >- if (index == -1) >- continue; >- author = href.substring(index + 7); >- break; >- } >- } >- } >- } >- >- // get the author's real name >- StringBuffer sb = new StringBuffer(); >- for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.A && tag.isEndTag()) >- break; >- } else if (token.getType() == Token.TEXT) { >- if (sb.length() > 0) { >- sb.append(' '); >- } >- sb.append((StringBuffer) token.getValue()); >- } >- } >- authorName = sb.toString(); >- >- // get the comment's date >- sb.setLength(0); >- for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.I && tag.isEndTag()) >- break; >- } else if (token.getType() == Token.TEXT) { >- if (sb.length() > 0) { >- sb.append(' '); >- } >- sb.append((StringBuffer) token.getValue()); >- } >- } >- try { >- if (sb.length() >= 16) { >- date = df.parse(sb.substring(0, 16)); >- } >- } catch (Exception e) { >- date = Calendar.getInstance().getTime(); // XXX: could not >- // determine date >- } >- return new Comment(bug, number, date, author, authorName); >- } >- >- /** >- * Parse the case where we have comment text >- * >- * @param in >- * The input stream for the bug >- * @param bug >- * The bug report for the current bug >- * @param comment >- * The comment to add the text to >- * @throws IOException >- */ >- private static void parseCommentText(BugReport bug, Comment comment, HtmlStreamTokenizer tokenizer) >- throws IOException, ParseException { >- >- StringBuffer commentStringBuffer = new StringBuffer(); >- for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagName().equals(TAG_SPAN)) { >- if(tag.hasAttribute(ATTRIBUTE_CLASS) && tag.getAttribute(ATTRIBUTE_CLASS).equals("")) { >- parseAttachment(commentStringBuffer, comment, tokenizer, false); >- continue; >- } else if(tag.hasAttribute(ATTRIBUTE_CLASS) && tag.getAttribute(ATTRIBUTE_CLASS).equals(VALUE_ATTACHMENT_OBSOLETE)) { >- parseAttachment(commentStringBuffer, comment, tokenizer, true); >- continue; >- } >- } >- // added to ensure whitespace is not >- // lost if adding a tag within a tag >- if (commentStringBuffer.length() > 0) { >- commentStringBuffer.append(token.getWhitespace()); >- } >- if (tag.getTagType() == HtmlTag.Type.PRE && tag.isEndTag()) >- break; >- } else if (token.getType() == Token.TEXT) { >- if (commentStringBuffer.length() > 0) { >- commentStringBuffer.append(token.getWhitespace()); >- } >- commentStringBuffer.append((StringBuffer) token.getValue()); >- } >- // remove attachment description from comment body >- if (comment.hasAttachment() && commentStringBuffer.indexOf(comment.getAttachmentDescription()) == 0) { >- commentStringBuffer = new StringBuffer(); >- } >- } >- >- HtmlStreamTokenizer.unescape(commentStringBuffer); >- comment.setText(commentStringBuffer.toString()); >- bug.addComment(comment); >- } >- >- private static void parseAttachment(StringBuffer stringBuffer, Comment comment, HtmlStreamTokenizer tokenizer, boolean obsolete) >- throws IOException, ParseException { >- >- int attachmentID = -1; >- String attachmentDescription = ""; >- for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- >- if (tag.getTagType() == HtmlTag.Type.A && !comment.hasAttachment()) { >- if (tag.getAttribute(ATTRIBUTE_ID_HREF) != null) { >- String link = tag.getAttribute(ATTRIBUTE_ID_HREF); >- if (link.startsWith(ATTACHMENT_CGI_ID)) { >- try { >- int endIndex = link.indexOf("&"); >- if (endIndex > 0 && endIndex < link.length()) { >- attachmentID = Integer.parseInt(link >- .substring(ATTACHMENT_CGI_ID.length(), endIndex)); >- } >- } catch (NumberFormatException e) { >- return; >- } >- } >- if (tag.getAttribute(ATTRIBUTE_ID_TITLE) != null) { >- attachmentDescription = tag.getAttribute(ATTRIBUTE_ID_TITLE); >- } >- if (attachmentID > 0) { >- comment.setHasAttachment(true); >- comment.setAttachmentId(attachmentID); >- comment.setAttachmentDescription(attachmentDescription); >- comment.setObsolete(obsolete); >- } >- >- } >- } >- if (tag.getTagName().equals(TAG_SPAN) && tag.isEndTag()) >- break; >- } >- } >- } >- >- /** >- * Parse the full html version of the bug >- * >- * @param in - >- * the input stream for the bug >- * @param id - >- * the id of the bug that is to be parsed >- * @return A bug report for the bug that was parsed >- * @throws IOException >- * @throws ParseException >- */ >- public static BugReport parseBug(Reader in, int id, String serverUrl, boolean is218, String userName, >- String password, String contentType) throws IOException, ParseException, LoginException { >- // create a new bug report and set the parser state to the start state >- BugReport bug = new BugReport(id, serverUrl); >- boolean contentTypeResolved = false; >- if (contentType != null) { >- String charsetFromContentType = getCharsetFromString(contentType); >- if (charsetFromContentType != null) { >- bug.setCharset(charsetFromContentType); >- contentTypeResolved = true; >- } >- } >- ParserState state = ParserState.START; >- Comment comment = null; >- String attribute = null; >- >- HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(in, null); >- >- boolean isTitle = false; >- boolean possibleBadLogin = false; >- boolean checkBody = false; >- String title = ""; >- StringBuffer body = new StringBuffer(); >- >- for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >- >- // get the charset from the HTML if not specified >- if (!contentTypeResolved) { >- if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.META >- && !((HtmlTag) (token.getValue())).isEndTag()) { >- String charsetFromHtml = getCharsetFromString(token.toString()); >- if (charsetFromHtml != null) >- bug.setCharset(charsetFromHtml); >- } >- } >- >- // make sure that bugzilla doesn't want us to login >- if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.TITLE >- && !((HtmlTag) (token.getValue())).isEndTag()) { >- isTitle = true; >- continue; >- } >- >- if (isTitle) { >- // get all of the data in the title tag >- if (token.getType() != Token.TAG) { >- title += ((StringBuffer) token.getValue()).toString().toLowerCase() + " "; >- continue; >- } else if (token.getType() == Token.TAG >- && ((HtmlTag) token.getValue()).getTagType() == HtmlTag.Type.TITLE >- && ((HtmlTag) token.getValue()).isEndTag()) { >- // check and see if the title seems as though we have wrong >- // login info >- if (title.indexOf("login") != -1 >- || (title.indexOf("invalid") != -1 && title.indexOf("password") != -1) >- || title.indexOf("check e-mail") != -1) >- possibleBadLogin = true; // we possibly have a bad >- // login >- >- // if the title starts with error, we may have a login >- // problem, or >- // there is a problem with the bug (doesn't exist), so we >- // must do >- // some more checks >- if (title.startsWith("error")) >- checkBody = true; >- >- isTitle = false; >- title = ""; >- } >- continue; >- } >- >- // if we have to add all of the text so that we can check it later >- // for problems with the username and password >- if (checkBody && token.getType() == Token.TEXT) { >- body.append((StringBuffer) token.getValue()); >- body.append(" "); >- } >- >- // we have found the start of an attribute name >- if ((state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.TD && "right".equalsIgnoreCase(tag.getAttribute("align"))) { >- // parse the attribute's name >- attribute = parseAttributeName(tokenizer); >- if (attribute != null && attribute.contains(IBugzillaConstants.INVALID_2201_ATTRIBUTE_IGNORED)) { >- continue; >- } >- if (attribute.toLowerCase().startsWith("opened")) { >- // find the colon so we can get the date >- int index = attribute.toLowerCase().indexOf(":"); >- String date; >- if (index != -1) >- date = attribute.substring(index + 1).trim(); >- else >- date = attribute.substring(6).trim(); >- >- // set the bugs opened date to be the date we parsed >- bug.setCreated(df.parse(date)); >- state = ParserState.ATT_NAME; >- continue; >- } >- >- // in 2.18, the last modified looks like the opened so we >- // need to parse it differently >- if (attribute.toLowerCase().startsWith("last modified") && is218) { >- // find the colon so we can get the date >- int index = attribute.toLowerCase().indexOf(":"); >- String date; >- if (index != -1) >- date = attribute.substring(index + 1).trim(); >- else >- date = attribute.substring(6).trim(); >- >- // create a new attribute and set the date >- Attribute t = new Attribute("Last Modified"); >- t.setValue(date); >- >- // add the attribute to the bug report >- bug.addAttribute(t); >- bug.setLastModified(df.parse(date)); >- state = ParserState.ATT_NAME; >- continue; >- } >- >- state = ParserState.ATT_VALUE; >- continue; >- } else if (tag.getTagType() == HtmlTag.Type.INPUT && "radio".equalsIgnoreCase(tag.getAttribute("type")) >- && "knob".equalsIgnoreCase(tag.getAttribute(KEY_NAME))) { >- // we found a radio button >- parseOperations(bug, tokenizer, tag, is218); >- } >- } >- >- // we have found the start of attribute values >- if (state == ParserState.ATT_VALUE && token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.TD) { >- // parse the attribute values >- parseAttributeValue(bug, attribute, tokenizer, serverUrl, userName, password); >- >- state = ParserState.ATT_NAME; >- attribute = null; >- continue; >- } >- } >- >- // we have found the start of a comment >- if (state == ParserState.DESC_START && token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.I) { >- // parse the comment's start >- comment = parseCommentHead(bug, tokenizer); >- >- state = ParserState.DESC_VALUE; >- continue; >- } >- } >- >- // we have found the start of the comment text >- if (state == ParserState.DESC_VALUE && token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.PRE) { >- // parse the text of the comment >- parseCommentText(bug, comment, tokenizer); >- >- comment = null; >- state = ParserState.DESC_START; >- continue; >- } >- } >- >- // last modification date >- if (bug.getCreated() == null && (state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.DIV && tag.getAttribute("id") != null && "header".equalsIgnoreCase(tag.getAttribute("id"))) { >- StringBuffer sb = new StringBuffer(); >- parseLastModified(sb, tokenizer); >- if(sb.length() > 0) { >- int index = sb.indexOf(":"); >- String date; >- if (index != -1) >- date = sb.substring(index + 1).trim(); >- else >- date = sb.substring(6).trim(); >- >- // create a new attribute and set the date >- Attribute t = new Attribute("Last Modified"); >- t.setValue(date); >- >- // add the attribute to the bug report >- bug.setLastModified(df.parse(date)); >- bug.addAttribute(t); >- } >- continue; >- } >- } >- >- >- // look for date opened field >- if (bug.getCreated() == null && (state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.TD && tag.getAttribute("align") != null && "left".equalsIgnoreCase(tag.getAttribute("align")) && tag.getAttribute("width") != null && "30%".equals(tag.getAttribute("width"))) { >- StringBuffer sb = new StringBuffer(); >- parseDateOpened(sb, tokenizer); >- if(sb.length() > 0) { >- int index = sb.indexOf(":"); >- String date; >- if (index != -1) >- date = sb.substring(index + 1).trim(); >- else >- date = sb.substring(6).trim(); >- >- // set the bugs opened date to be the date we parsed >- bug.setCreated(df.parse(date)); >- } >- continue; >- } >- } >- >- // we have found the description of the bug >- if ((state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.PRE) { >- // parse the description for the bug >- parseDescription(bug, tokenizer); >- >- state = ParserState.DESC_START; >- continue; >- } >- } >- >- // parse hidden fields >- >- if ((state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.INPUT && tag.getAttribute("type") != null >- && "hidden".equalsIgnoreCase(tag.getAttribute("type").trim())) { >- >- Attribute a = new Attribute(tag.getAttribute(KEY_NAME)); >- a.setParameterName(tag.getAttribute(KEY_NAME)); >- a.setValue(tag.getAttribute(KEY_VALUE)); >- a.setHidden(true); >- bug.addAttribute(a); >- continue; >- } >- } >- >- // // parse out attachments >- // if(token.getType() == Token.TAG) { >- // HtmlTag tag = (HtmlTag) token.getValue(); >- // if(tag.getTagType() == HtmlTag.Type.A && tag.getAttribute("href") >- // != null) { >- // String link = tag.getAttribute("href"); >- // if(link.startsWith("attachment.cgi?id=") && >- // !link.contains("action")) { >- // int attachmentID = Integer.parseInt(link.substring(18)); >- // String description = parseAttachementDescription(tokenizer); >- // bug.addAttachment(attachmentID, description); >- // } >- // } >- // } >- >- } >- >- // if we are to check the body, make sure that there wasn't a bad login >- if (checkBody) { >- String b = body.toString(); >- if (b.indexOf("login") != -1 >- || ((b.indexOf("invalid") != -1 || b.indexOf("not valid") != -1) && b.indexOf("password") != -1) >- || b.indexOf("check e-mail") != -1) >- possibleBadLogin = true; // we possibly have a bad login >- } >- >- // if there is no summary or created date, we expect that >- // the bug doesn't exist, so set it to null >- >- // if the bug seems like it doesn't exist, and we suspect a login >- // problem, assume that there was a login problem >- if (bug.getCreated() == null && bug.getAttributes().isEmpty()) { >- if (possibleBadLogin) { >- throw new LoginException(IBugzillaConstants.MESSAGE_LOGIN_FAILURE); >- } else { >- return null; >- } >- } >- // we are done...return the bug >- return bug; >- } >- >- private static void parseDateOpened(StringBuffer sb, HtmlStreamTokenizer tokenizer) throws IOException, ParseException { >- for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.TD && tag.isEndTag()) >- break; >- } else if (token.getType() == Token.TEXT) { >- if (sb.length() > 0) { >- sb.append(' '); >- } >- sb.append((StringBuffer) token.getValue()); >- } >- } >- >- } >- >- private static void parseLastModified(StringBuffer sb, HtmlStreamTokenizer tokenizer) throws IOException, ParseException { >- boolean inH3 = false; >- for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >- if (token.getType() == Token.TAG) { >- HtmlTag tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.H3 && !tag.isEndTag()) { >- inH3 = true; >- continue; >- } else if (tag.getTagType() == HtmlTag.Type.DIV && tag.isEndTag()) { >- break; >- } >- } else if (token.getType() == Token.TEXT && inH3) { >- if (sb.length() > 0) { >- sb.append(' '); >- } >- sb.append((StringBuffer) token.getValue()); >- } >- } >- >- } >- >- public static String getCharsetFromString(String string) { >- int charsetStartIndex = string.indexOf(ATTR_CHARSET); >- if (charsetStartIndex != -1) { >- int charsetEndIndex = string.indexOf("\"", charsetStartIndex); // TODO: >- // could >- // be >- // space >- // after? >- if (charsetEndIndex == -1) { >- charsetEndIndex = string.length(); >- } >- String charsetString = string.substring(charsetStartIndex + 8, charsetEndIndex); >- if (Charset.availableCharsets().containsKey(charsetString)) { >- return charsetString; >- } >- } >- return null; >- } >- >- /** >- * Parse the operations that are allowed on the bug (Assign, Re-open, fix) >- * >- * @param bug >- * The bug to add the operations to >- * @param tokenizer >- * The stream tokenizer for the bug >- * @param tag >- * The last tag that we were on >- */ >- private static void parseOperations(BugReport bug, HtmlStreamTokenizer tokenizer, HtmlTag tag, boolean is218) >- throws ParseException, IOException { >- >- String knobName = tag.getAttribute(KEY_VALUE); >- boolean isChecked = false; >- if (tag.getAttribute("checked") != null && tag.getAttribute("checked").equals("checked")) >- isChecked = true; >- StringBuffer sb = new StringBuffer(); >- >- Token lastTag = null; >- >- for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >- if (token.getType() == Token.TAG) { >- tag = (HtmlTag) token.getValue(); >- >- if (!(tag.getTagType() == HtmlTag.Type.A || tag.getTagType() == HtmlTag.Type.B >- || tag.getTagType() == HtmlTag.Type.STRONG || tag.getTagType() == HtmlTag.Type.LABEL)) { >- lastTag = token; >- break; >- } else { >- >- if (is218 && tag.getTagType() == HtmlTag.Type.LABEL) { >- continue; >- } else if (tag.getTagType() == HtmlTag.Type.A || tag.getTagType() == HtmlTag.Type.B >- || tag.getTagType() == HtmlTag.Type.STRONG) { >- sb.append(tag.toString().trim() + " "); >- } else { >- break; >- } >- } >- } else if (token.getType() == Token.TEXT && !token.toString().trim().equals("\n")) >- sb.append(token.toString().trim() + " "); >- } >- >- String displayName = HtmlStreamTokenizer.unescape(sb).toString(); >- Operation o = new Operation(knobName, displayName); >- o.setChecked(isChecked); >- >- if (lastTag != null) { >- tag = (HtmlTag) lastTag.getValue(); >- if (tag.getTagType() != HtmlTag.Type.SELECT) { >- tokenizer.pushback(lastTag); >- if (tag.getTagType() == HtmlTag.Type.INPUT >- && !("radio".equalsIgnoreCase(tag.getAttribute("type")) && "knob".equalsIgnoreCase(tag >- .getAttribute(KEY_NAME)))) { >- o.setInputName(((HtmlTag) lastTag.getValue()).getAttribute(KEY_NAME)); >- o.setInputValue(((HtmlTag) lastTag.getValue()).getAttribute(KEY_VALUE)); >- } >- } else { >- Token token = tokenizer.nextToken(); >- // parse the options >- >- tag = (HtmlTag) token.getValue(); >- o.setUpOptions(((HtmlTag) lastTag.getValue()).getAttribute(KEY_NAME)); >- >- while (token.getType() != Token.EOF) { >- if (token.getType() == Token.TAG) { >- tag = (HtmlTag) token.getValue(); >- if (tag.getTagType() == HtmlTag.Type.SELECT && tag.isEndTag()) >- break; >- if (tag.getTagType() == HtmlTag.Type.OPTION && !tag.isEndTag()) { >- String optionName = tag.getAttribute(KEY_VALUE); >- StringBuffer optionText = new StringBuffer(); >- for (token = tokenizer.nextToken(); token.getType() == Token.TEXT; token = tokenizer >- .nextToken()) { >- if (optionText.length() > 0) { >- optionText.append(' '); >- } >- optionText.append((StringBuffer) token.getValue()); >- } >- o.addOption(optionText.toString(), optionName); >- } else { >- token = tokenizer.nextToken(); >- } >- } else { >- token = tokenizer.nextToken(); >- } >- } >- } >- } >- >- bug.addOperation(o); >- } >- >- /** >- * Enum class for describing current state of Bugzilla report parser. >- */ >- private static class ParserState { >- /** An instance of the start state */ >- protected static final ParserState START = new ParserState("start"); >- >- /** An instance of the state when the parser found an attribute name */ >- protected static final ParserState ATT_NAME = new ParserState("att_name"); >- >- /** An instance of the state when the parser found an attribute value */ >- protected static final ParserState ATT_VALUE = new ParserState("att_value"); >- >- /** An instance of the state when the parser found a description */ >- protected static final ParserState DESC_START = new ParserState("desc_start"); >- >- /** An instance of the state when the parser found a description value */ >- protected static final ParserState DESC_VALUE = new ParserState("desc_value"); >- >- /** State's human-readable name */ >- private String name; >- >- /** >- * Constructor >- * >- * @param description - >- * The states human readable name >- */ >- private ParserState(String description) { >- this.name = description; >- } >- >- @Override >- public String toString() { >- return name; >- } >- } >-} >Index: src/org/eclipse/mylar/internal/bugzilla/core/internal/BugReportElement.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/bugzilla/core/internal/BugReportElement.java >diff -N src/org/eclipse/mylar/internal/bugzilla/core/internal/BugReportElement.java >--- src/org/eclipse/mylar/internal/bugzilla/core/internal/BugReportElement.java 28 Apr 2006 20:41:44 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,85 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylar.internal.bugzilla.core.internal; >- >-/** >- * Bugzilla XML element enum. Each enum has the field name >- * and associated xml element tag name. >- * >- * @author Rob Elves >- */ >-public enum BugReportElement { >- >- // Format: ENUM ( "pretty name", "xml key" ) >- >- BUGZILLA ("bugzilla", "bugzilla"), >- BUG ("bug","bug"), >- BUG_ID ("Bug", "bug_id"), >- CREATION_TS ("Creation Date", "creation_ts"), >- SHORT_DESC ("Summary", "short_desc"), >- DELTA_TS ("Last Modification", "delta_ts"), >- REPORTER_ACCESSIBLE ("reporter_accessible", "reporter_accessible"), >- CCLIST_ACCESSIBLE ("cclist_accessible", "cclist_accessible"), >- CLASSIFICATION_ID ("Classification ID", "classification_id"), >- CLASSIFICATION ("Classification", "classification"), >- PRODUCT ("Product", "product"), >- COMPONENT ("Component", "component"), >- VERSION ("Version", "version"), >- REP_PLATFORM ("Platform", "rep_platform"), >- OP_SYS ("OS", "op_sys"), >- BUG_STATUS ("Status", "bug_status"), >- PRIORITY ("Priority", "priority"), >- BUG_SEVERITY ("Severity", "bug_severity"), >- TARGET_MILESTONE ("Target Milestone", "target_milestone"), >- EVERCONFIRMED ("everconfirmed", "everconfirmed"), >- REPORTER ("Reporter", "reporter"), >- ASSIGNED_TO ("Assigned To", "assigned_to"), >- CC ("CC", "cc"), >- LONG_DESC ("Description", "long_desc"), >- WHO ("who", "who"), >- BUG_WHEN ("bug_when", "bug_when"), >- THETEXT ("thetext", "thetext"), >- ATTACHMENT ("attachment", "attachment"), >- ATTACHID ("attachid", "attachid"), >- DATE ("Date", "date"), >- DESC ("desc", "desc"), >- FILENAME ("filename", "filename"), >- TYPE ("type", "type"), >- DATA ("data", "data"), >- BUG_FILE_LOC ("URL", "bug_file_loc"), >- UNKNOWN ("UNKNOWN", "UNKNOWN"); >- >- private final String prettyName; >- private final String keyString; >- >- BugReportElement(String prettyName, String fieldName) { >- this.prettyName = prettyName; >- keyString = fieldName; >- } >- >- public String getKeyString() { >- return keyString; >- } >- >- public String toString() { >- return prettyName; >- } >- >-// public BugReportElementTag fromString(String str) { >-// for (BugReportElementTag tag : BugReportElementTag.values()) { >-// if (tag.toString().equals(str)) { >-// return tag; >-// } >-// } >-// return UNKNOWN; >-// } >-} >Index: src/org/eclipse/mylar/internal/bugzilla/core/compare/BugzillaCompareNode.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/compare/BugzillaCompareNode.java,v >retrieving revision 1.2 >diff -u -r1.2 BugzillaCompareNode.java >--- src/org/eclipse/mylar/internal/bugzilla/core/compare/BugzillaCompareNode.java 22 Feb 2006 22:35:19 -0000 1.2 >+++ src/org/eclipse/mylar/internal/bugzilla/core/compare/BugzillaCompareNode.java 8 May 2006 23:07:24 -0000 >@@ -22,8 +22,8 @@ > import org.eclipse.compare.ITypedElement; > import org.eclipse.compare.structuremergeviewer.IStructureComparator; > import org.eclipse.core.runtime.CoreException; >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.bugzilla.core.Comment; > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.ISharedImages; >@@ -190,7 +190,7 @@ > * The <code>BugReport</code> that needs parsing. > * @return The tree of <code>BugzillaCompareNode</code>'s. > */ >- public static BugzillaCompareNode parseBugReport(BugReport bug) { >+ public static BugzillaCompareNode parseBugReport(BugzillaReport bug) { > Image defaultImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEF_VIEW); > BugzillaCompareNode topNode = new BugzillaCompareNode("Bug #" + bug.getId(), null, defaultImage); > Date creationDate = bug.getCreated(); >@@ -211,8 +211,8 @@ > > Image attributeImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT); > BugzillaCompareNode attributes = new BugzillaCompareNode("Attributes", null, attributeImage); >- for (Iterator<Attribute> iter = bug.getAttributes().iterator(); iter.hasNext();) { >- Attribute attribute = iter.next(); >+ for (Iterator<AbstractRepositoryReportAttribute> iter = bug.getAttributes().iterator(); iter.hasNext();) { >+ AbstractRepositoryReportAttribute attribute = iter.next(); > if (attribute.getName().compareTo("delta_ts") == 0 || attribute.getName().compareTo("Last Modified") == 0 > || attribute.getName().compareTo("longdesclength") == 0) > continue; >@@ -220,7 +220,7 @@ > // attribute's new > // value, which is what is in the submit viewer. > >- attributes.addChild(new BugzillaCompareNode(attribute.getName(), attribute.getNewValue(), attributeImage)); >+ attributes.addChild(new BugzillaCompareNode(attribute.getName(), attribute.getValue(), attributeImage)); > } > topNode.addChild(attributes); > >@@ -229,12 +229,12 @@ > BugzillaCompareNode comments = new BugzillaCompareNode("Comments", null, defaultImage); > for (Iterator<Comment> iter = bug.getComments().iterator(); iter.hasNext();) { > Comment comment = iter.next(); >- String bodyString = "Comment from " + comment.getAuthorName() + ":\n\n" + comment.getText(); >+ String bodyString = "Comment from " + comment.getAuthorName() + ":\n\n" + comment.getText(); > comments.addChild(new BugzillaCompareNode(comment.getCreated().toString(), bodyString, defaultImage)); > } > topNode.addChild(comments); > >- topNode.addChild(new BugzillaCompareNode("New Comment", bug.getNewNewComment(), defaultImage)); >+ topNode.addChild(new BugzillaCompareNode("New Comment", bug.getNewComment(), defaultImage)); > > BugzillaCompareNode ccList = new BugzillaCompareNode("CC List", null, defaultImage); > for (Iterator<String> iter = bug.getCC().iterator(); iter.hasNext();) { >Index: src/org/eclipse/mylar/internal/bugzilla/core/compare/BugzillaCompareInput.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/compare/BugzillaCompareInput.java,v >retrieving revision 1.1 >diff -u -r1.1 BugzillaCompareInput.java >--- src/org/eclipse/mylar/internal/bugzilla/core/compare/BugzillaCompareInput.java 24 Jan 2006 19:55:42 -0000 1.1 >+++ src/org/eclipse/mylar/internal/bugzilla/core/compare/BugzillaCompareInput.java 8 May 2006 23:07:24 -0000 >@@ -16,7 +16,7 @@ > import org.eclipse.compare.structuremergeviewer.Differencer; > import org.eclipse.compare.structuremergeviewer.IStructureComparator; > import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > > /** > * A two-way or three-way compare for <code>BugReport</code> objects. >@@ -72,7 +72,7 @@ > * @param newAncestor > * The new original object. > */ >- public void setAncestor(BugReport newAncestor) { >+ public void setAncestor(BugzillaReport newAncestor) { > threeWay = (newAncestor != null); > BugzillaStructureCreator structureCreator = new BugzillaStructureCreator(); > ancestor = structureCreator.getStructure(newAncestor); >@@ -93,7 +93,7 @@ > * @param newLeft > * The new local object. > */ >- public void setLeft(BugReport newLeft) { >+ public void setLeft(BugzillaReport newLeft) { > BugzillaStructureCreator structureCreator = new BugzillaStructureCreator(); > left = structureCreator.getStructure(newLeft); > } >@@ -113,7 +113,7 @@ > * @param newRight > * The new online object. > */ >- public void setRight(BugReport newRight) { >+ public void setRight(BugzillaReport newRight) { > BugzillaStructureCreator structureCreator = new BugzillaStructureCreator(); > right = structureCreator.getStructure(newRight); > } >Index: src/org/eclipse/mylar/internal/bugzilla/core/compare/BugzillaStructureCreator.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/compare/BugzillaStructureCreator.java,v >retrieving revision 1.1 >diff -u -r1.1 BugzillaStructureCreator.java >--- src/org/eclipse/mylar/internal/bugzilla/core/compare/BugzillaStructureCreator.java 24 Jan 2006 19:55:42 -0000 1.1 >+++ src/org/eclipse/mylar/internal/bugzilla/core/compare/BugzillaStructureCreator.java 8 May 2006 23:07:24 -0000 >@@ -14,7 +14,7 @@ > import org.eclipse.compare.structuremergeviewer.IStructureComparator; > import org.eclipse.compare.structuremergeviewer.IStructureCreator; > import org.eclipse.jface.util.Assert; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > > /** > * This implementation of the <code>IStructureCreator</code> interface makes >@@ -38,8 +38,8 @@ > } > > public IStructureComparator getStructure(Object input) { >- if (input instanceof BugReport) { >- BugReport bugReport = (BugReport) input; >+ if (input instanceof BugzillaReport) { >+ BugzillaReport bugReport = (BugzillaReport) input; > return BugzillaCompareNode.parseBugReport(bugReport); > } else { > return null; >Index: src/org/eclipse/mylar/internal/bugzilla/core/NewBugModel.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/bugzilla/core/NewBugModel.java >diff -N src/org/eclipse/mylar/internal/bugzilla/core/NewBugModel.java >--- src/org/eclipse/mylar/internal/bugzilla/core/NewBugModel.java 28 Apr 2006 20:41:44 -0000 1.7 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,224 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2003 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.mylar.internal.bugzilla.core; >- >-import java.io.Serializable; >-import java.util.ArrayList; >-import java.util.Date; >-import java.util.Iterator; >-import java.util.LinkedHashMap; >-import java.util.List; >-import java.util.Map; >- >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.bugzilla.core.IBugzillaBug; >- >-/** >- * This class is used to store data about the new bug that is being created >- * while the wizard is being used >- * >- * @author Eric Booth >- */ >-public class NewBugModel implements Serializable, IBugzillaBug { >- >- /** Automatically generated serialVersionUID */ >- private static final long serialVersionUID = 3977859587934335283L; >- >- /** Whether the attributes have been parsed yet or not */ >- protected boolean hasParsedAttributes = false; >- >- /** Whether the products have been parsed yet or not */ >- protected boolean hasParsedProducts = false; >- >- /** The bug's id */ >- protected final int id; >- >- /** The product that the bug is for */ >- protected String product; >- >- /** A list of the attributes that can be changed for the new bug */ >- public Map<String, Attribute> attributes = new LinkedHashMap<String, Attribute>(); >- >- /** The summary for the bug */ >- protected String summary = ""; >- >- /** The description for the bug */ >- protected String description = ""; >- >- /** >- * Flag to indicate status of connection to Bugzilla server to identify >- * whether ProductConfiguration should be used instead >- */ >- protected boolean connected = true; >- >- /** Whether or not this bug report is saved offline. */ >- protected boolean savedOffline = false; >- >- /** >- * Creates a new <code>NewBugModel</code>. The id chosen for this bug is >- * based on the id of the last <code>NewBugModel</code> that was created. >- */ >- public NewBugModel() { >- super(); >- id = BugzillaPlugin.getDefault().getOfflineReports().getNextOfflineBugId(); >- } >- >- public Attribute getAttribute(String key) { >- return attributes.get(key); >- } >- >- /** >- * Get the list of attributes for this model >- * >- * @return An <code>ArrayList</code> of the models attributes >- */ >- public List<Attribute> getAttributes() { >- // create an array list to store the attributes in >- ArrayList<Attribute> attributeEntries = new ArrayList<Attribute>(attributes.keySet().size()); >- >- // go through each of the attribute keys >- for (Iterator<String> it = attributes.keySet().iterator(); it.hasNext();) { >- // get the key for the attribute >- String key = it.next(); >- >- // get the attribute and add it to the list >- Attribute attribute = attributes.get(key); >- attributeEntries.add(attribute); >- } >- >- // return the list of attributes for the bug >- return attributeEntries; >- } >- >- public int getId() { >- return id; >- } >- >- public String getRepositoryUrl() { >- return BugzillaTools.OFFLINE_SERVER_DEFAULT; >- } >- >- public String getLabel() { >- return "New Bug #" + id; >- } >- >- public String getDescription() { >- return description; >- } >- >- public void setDescription(String newDescription) { >- description = newDescription; >- } >- >- public String getSummary() { >- return summary; >- } >- >- public void setSummary(String newSummary) { >- summary = newSummary; >- } >- >- /** >- * @return The product that the bug is for. >- */ >- public String getProduct() { >- return product; >- } >- >- /** >- * Sets the product that the bug is for. >- * >- * @param product >- * The product. >- */ >- public void setProduct(String product) { >- this.product = product; >- } >- >- /** >- * @return Flag to indicate status of connection to Bugzilla server (to >- * identify whether ProductConfiguration should be used instead) >- */ >- public boolean isConnected() { >- return connected; >- } >- >- /** >- * Sets the value of the flag to indicate status of connection to Bugzilla >- * server (to identify whether ProductConfiguration should be used instead) >- * >- * @param newConnectionStatus >- * <code>true</code> if the bug is connected. >- */ >- public void setConnected(boolean newConnectionStatus) { >- connected = newConnectionStatus; >- } >- >- /** >- * @return Returns whether the attributes have been parsed yet or not. >- */ >- public boolean hasParsedAttributes() { >- return hasParsedAttributes; >- } >- >- /** >- * Sets whether the attributes have been parsed yet or not. >- * >- * @param hasParsedAttributes >- * <code>true</code> if the attributes have been parsed. >- */ >- public void setParsedAttributesStatus(boolean hasParsedAttributes) { >- this.hasParsedAttributes = hasParsedAttributes; >- } >- >- /** >- * @return Returns whether the products have been parsed yet or not. >- */ >- public boolean hasParsedProducts() { >- return hasParsedProducts; >- } >- >- /** >- * Sets whether the products have been parsed yet or not. >- * >- * @param hasParsedProducts >- * <code>true</code> if the products have been parsed. >- */ >- public void setParsedProductsStatus(boolean hasParsedProducts) { >- this.hasParsedProducts = hasParsedProducts; >- } >- >- public boolean isSavedOffline() { >- return savedOffline; >- } >- >- public boolean isLocallyCreated() { >- return true; >- } >- >- public void setOfflineState(boolean newOfflineState) { >- savedOffline = newOfflineState; >- } >- >- public boolean hasChanges() { >- return true; >- } >- >- /** returns null */ >- public Date getCreated() { >- return null; >- } >- >- public Date getLastModified() { >- return null; >- } >- >-} >Index: src/org/eclipse/mylar/internal/bugzilla/core/IBugzillaConstants.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/IBugzillaConstants.java,v >retrieving revision 1.8 >diff -u -r1.8 IBugzillaConstants.java >--- src/org/eclipse/mylar/internal/bugzilla/core/IBugzillaConstants.java 28 Apr 2006 23:42:19 -0000 1.8 >+++ src/org/eclipse/mylar/internal/bugzilla/core/IBugzillaConstants.java 8 May 2006 23:07:24 -0000 >@@ -58,9 +58,13 @@ > static final String HIT_MARKER_ATTR_OWNER = "owner"; > > static final String HIT_MARKER_ATTR_QUERY = "query"; >+ > >- // Error code >- static final int ERROR_CODE = 1; >+ >+ // Error response from bugzilla server upon bug request >+ static final String ERROR_INVALID_BUG_ID = "InvalidBugId"; >+ static final String ERROR_INVALID_USERNAME_OR_PASSWORD = "Invalid Username Or Password"; >+// static final int ERROR_CODE = 1; > > // Bugzilla Preferences keys > // static final String BUGZILLA_SERVER = "BUGZILLA_SERVER"; >@@ -146,8 +150,9 @@ > > static final String[] DEFAULT_PRESELECTED_STATUS_VALUES = { "New", "Assigned", "Reopened" }; > >- static final String[] DEFAULT_RESOLUTION_VALUES = { "Fixed", "Invalid", "Wontfix", "Later", "Remind", "Duplicate", >- "Worksforme", "Moved" }; >+ // static final String[] DEFAULT_RESOLUTION_VALUES = { "Fixed", "Invalid", >+ // "Wontfix", "Later", "Remind", "Duplicate", >+ // "Worksforme", "Moved" }; > > static final String[] DEFAULT_SEVERITY_VALUES = { "blocker", "critical", "major", "normal", "minor", "trivial", > "enhancement" }; >@@ -176,4 +181,21 @@ > > public static final String INVALID_2201_ATTRIBUTE_IGNORED = "EclipsebugsBugzilla2.20.1"; > >+ public static final String VALUE_STATUS_RESOLVED = "RESOLVED"; >+ public static final String VALUE_STATUS_NEW = "NEW"; >+ public static final String VALUE_STATUS_CLOSED = "CLOSED"; >+ public static final String VALUE_STATUS_ASSIGNED = "ASSIGNED"; >+ public static final String VALUE_RESOLUTION_LATER = "LATER"; >+ >+ public static enum BUGZILLA_OPERATION { >+ none, accept, resolve, duplicate, reassign, reassignbycomponent, reopen, verify, close; >+ } >+ >+ public static enum BUGZILLA_REPORT_STATUS { >+ UNCONFIRMED, NEW, ASSIGNED, REOPENED, RESOLVED, VERIFIED, CLOSED; >+ } >+ >+ public static enum BUGZILLA_RESOLUTION { >+ FIXED, INVALID, WONTFIX, LATER, REMIND, WORKSFORME; >+ } > } >Index: src/org/eclipse/mylar/internal/bugzilla/core/BugzillaRepositoryUtil.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/BugzillaRepositoryUtil.java,v >retrieving revision 1.20 >diff -u -r1.20 BugzillaRepositoryUtil.java >--- src/org/eclipse/mylar/internal/bugzilla/core/BugzillaRepositoryUtil.java 28 Apr 2006 23:42:19 -0000 1.20 >+++ src/org/eclipse/mylar/internal/bugzilla/core/BugzillaRepositoryUtil.java 8 May 2006 23:07:24 -0000 >@@ -22,9 +22,8 @@ > import java.net.URL; > import java.net.URLConnection; > import java.net.URLEncoder; >+import java.nio.charset.Charset; > import java.util.ArrayList; >-import java.util.HashMap; >-import java.util.LinkedHashMap; > import java.util.List; > > import javax.security.auth.login.LoginException; >@@ -44,14 +43,19 @@ > import org.eclipse.core.runtime.Status; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReportAttribute; > import org.eclipse.mylar.bugzilla.core.IBugzillaBug; >-import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser; >-import org.eclipse.mylar.internal.bugzilla.core.internal.BugReportElement; >+import org.eclipse.mylar.bugzilla.core.Operation; >+import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_OPERATION; >+import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_REPORT_STATUS; >+import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_RESOLUTION; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; > import org.eclipse.mylar.internal.bugzilla.core.internal.OfflineReportsFile; > import org.eclipse.mylar.internal.bugzilla.core.internal.RepositoryConfiguration; >-import org.eclipse.mylar.internal.bugzilla.core.internal.ServerConfigurationFactory; >+import org.eclipse.mylar.internal.bugzilla.core.internal.RepositoryConfigurationFactory; >+import org.eclipse.mylar.internal.bugzilla.core.internal.RepositoryReportFactory; > import org.eclipse.mylar.internal.core.util.MylarStatusHandler; > import org.eclipse.mylar.internal.core.util.ZipFileUtil; > import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin; >@@ -62,14 +66,38 @@ > > /** > * @author Mik Kersten (some rewriting) >- * @author Rob Elves (attachments) >+ * @author Rob Elves > */ > public class BugzillaRepositoryUtil { > >+ private static final String ATTR_CHARSET = "charset"; >+ >+ private static final String OPERATION_INPUT_ASSIGNED_TO = "assigned_to"; >+ >+ private static final String OPERATION_INPUT_DUP_ID = "dup_id"; >+ >+ private static final String OPERATION_OPTION_RESOLUTION = "resolution"; >+ >+ private static final String OPERATION_LABEL_CLOSE = "Mark bug as CLOSED"; >+ >+ private static final String OPERATION_LABEL_VERIFY = "Mark bug as VERIFIED"; >+ >+ private static final String OPERATION_LABEL_REOPEN = "Reopen bug"; >+ >+ private static final String OPERATION_LABEL_REASSIGN_DEFAULT = "Reassign bug to default assignee of selected component"; >+ >+ private static final String OPERATION_LABEL_REASSIGN = "Reassign bug to"; >+ >+ private static final String OPERATION_LABEL_DUPLICATE = "Resolve bug, mark it as duplicate of bug #"; >+ >+ private static final String OPERATION_LABEL_RESOLVE = "Resolve bug, changing resolution to"; >+ >+ private static final String OPERATION_LABEL_ACCEPT = "Accept bug (change status to ASSIGNED)"; >+ > private static final String BUG_STATUS_NEW = "NEW"; > > private static final String ATTACHMENT_DOWNLOAD_FAILED = "Attachment download FAILED."; >- >+ > private static final String VALUE_CONTENTTYPEMETHOD_MANUAL = "manual"; > > private static final String VALUE_ISPATCH = "1"; >@@ -108,7 +136,91 @@ > > private static final String POST_ARGS_LOGIN = "GoAheadAndLogIn=1&Bugzilla_login="; > >- public static BugReport getBug(String repositoryUrl, int id) throws IOException, MalformedURLException, >+ // public static BugReport getBug(String repositoryUrl, int id) throws >+ // IOException, MalformedURLException, >+ // LoginException { >+ // >+ // BufferedReader in = null; >+ // try { >+ // >+ // // create a new input stream for getting the bug >+ // TaskRepository repository = >+ // MylarTaskListPlugin.getRepositoryManager().getRepository( >+ // BugzillaPlugin.REPOSITORY_KIND, repositoryUrl); >+ // if (repository == null) { >+ // PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { >+ // public void run() { >+ // MessageDialog.openInformation(Display.getDefault().getActiveShell(), >+ // IBugzillaConstants.TITLE_MESSAGE_DIALOG, >+ // TaskRepositoryManager.MESSAGE_NO_REPOSITORY); >+ // } >+ // }); >+ // return null; >+ // } >+ // >+ // String url = repositoryUrl + POST_ARGS_SHOW_BUG + id; >+ // >+ // url = addCredentials(repository, url); >+ // >+ // URL bugUrl = new URL(url); >+ // URLConnection connection = >+ // BugzillaPlugin.getDefault().getUrlConnection(bugUrl); >+ // if (connection != null) { >+ // InputStream input = connection.getInputStream(); >+ // if (input != null) { >+ // in = new BufferedReader(new InputStreamReader(input)); >+ // // BugReport bugReport = new BugReport(id, >+ // // repository.getUrl()); >+ // // setupExistingBugAttributes2(repository.getUrl(), >+ // // bugReport); >+ // RepositoryReportFactory reportFactory = >+ // RepositoryReportFactory.getInstance(); >+ // AbstractRepositoryReport report = reportFactory.readReport(id, >+ // repository); >+ // >+ // BugReport bugReport = null; >+ // if (report != null && report instanceof BugReport) { >+ // bugReport = (BugReport) report; >+ // setupExistingBugAttributes(repository.getUrl(), bugReport); >+ // addValidOperations(bugReport); >+ // return bugReport; >+ // } >+ // // get the actual bug from the server and return it >+ // // BugReport bugReport = BugParser.parseBug(in, id, >+ // // repository.getUrl(), true, repository.getUserName(), >+ // // repository >+ // // .getPassword(), connection.getContentType()); >+ // // return bugReport; >+ // } >+ // } >+ // // TODO handle the error >+ // return null; >+ // } catch (MalformedURLException e) { >+ // throw e; >+ // } catch (IOException e) { >+ // throw e; >+ // } catch (LoginException e) { >+ // throw e; >+ // } catch (Exception e) { >+ // // BugzillaPlugin.log(new Status(IStatus.ERROR, >+ // // IBugzillaConstants.PLUGIN_ID, IStatus.ERROR, >+ // // "Problem getting report:\n"+e.getMessage(), e)); >+ // MylarStatusHandler.fail(e, "Problem getting report:\n" + e.getMessage(), >+ // false); >+ // return null; >+ // } finally { >+ // try { >+ // if (in != null) >+ // in.close(); >+ // } catch (IOException e) { >+ // BugzillaPlugin.log(new Status(IStatus.ERROR, >+ // IBugzillaConstants.PLUGIN_ID, IStatus.ERROR, >+ // "Problem closing the stream", e)); >+ // } >+ // } >+ // } >+ >+ public static BugzillaReport getBug(String repositoryUrl, int id) throws IOException, MalformedURLException, > LoginException { > > BufferedReader in = null; >@@ -129,12 +241,7 @@ > > String url = repositoryUrl + POST_ARGS_SHOW_BUG + id; > >- if (repository.hasCredentials()) { >- url += "&" + POST_ARGS_LOGIN >- + URLEncoder.encode(repository.getUserName(), BugzillaPlugin.ENCODING_UTF_8) >- + POST_ARGS_PASSWORD >- + URLEncoder.encode(repository.getPassword(), BugzillaPlugin.ENCODING_UTF_8); >- } >+ url = addCredentials(repository, url); > > URL bugUrl = new URL(url); > URLConnection connection = BugzillaPlugin.getDefault().getUrlConnection(bugUrl); >@@ -142,15 +249,17 @@ > InputStream input = connection.getInputStream(); > if (input != null) { > in = new BufferedReader(new InputStreamReader(input)); >+ BugzillaReport bugReport = new BugzillaReport(id, repository.getUrl()); >+ >+ setupExistingBugAttributes(repository.getUrl(), bugReport); >+ >+ RepositoryReportFactory reportFactory = RepositoryReportFactory.getInstance(); >+ reportFactory.populateReport(bugReport, repository); >+ updateBugAttributeOptions(repository, bugReport); >+ addValidOperations(bugReport); > >- // BugReportFactory reportFactory = >- // BugReportFactory.getInstance(); >- // BugReport bugReport = reportFactory.readReport(in, id, >- // repository, connection.getContentType()); >- // get the actual bug from the server and return it >- BugReport bugReport = BugParser.parseBug(in, id, repository.getUrl(), true, repository.getUserName(), repository >- .getPassword(), connection.getContentType()); > return bugReport; >+ > } > } > // TODO handle the error >@@ -162,8 +271,10 @@ > } catch (LoginException e) { > throw e; > } catch (Exception e) { >- BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.ERROR, >- "Problem getting report", e)); >+ // BugzillaPlugin.log(new Status(IStatus.ERROR, >+ // IBugzillaConstants.PLUGIN_ID, IStatus.ERROR, >+ // "Problem getting report:\n"+e.getMessage(), e)); >+ MylarStatusHandler.fail(e, "Problem getting report:\n" + e.getMessage(), false); > return null; > } finally { > try { >@@ -176,6 +287,14 @@ > } > } > >+ public static String addCredentials(TaskRepository repository, String url) throws UnsupportedEncodingException { >+ if (repository.hasCredentials()) { >+ url += "&" + POST_ARGS_LOGIN + URLEncoder.encode(repository.getUserName(), BugzillaPlugin.ENCODING_UTF_8) >+ + POST_ARGS_PASSWORD + URLEncoder.encode(repository.getPassword(), BugzillaPlugin.ENCODING_UTF_8); >+ } >+ return url; >+ } >+ > /** > * Get a bug from the server. If a bug with the given id is saved offline, > * the offline version is returned instead. >@@ -187,7 +306,7 @@ > * @throws IOException, > * MalformedURLException, LoginException > */ >- public static BugReport getCurrentBug(String repositoryUrl, int id) throws MalformedURLException, LoginException, >+ public static BugzillaReport getCurrentBug(String repositoryUrl, int id) throws MalformedURLException, LoginException, > IOException { > // Look among the offline reports for a bug with the given id. > OfflineReportsFile reportsFile = BugzillaPlugin.getDefault().getOfflineReports(); >@@ -196,8 +315,8 @@ > // If an offline bug was found, return it if possible. > if (offlineId != -1) { > IBugzillaBug bug = reportsFile.elements().get(offlineId); >- if (bug instanceof BugReport) { >- return (BugReport) bug; >+ if (bug instanceof BugzillaReport) { >+ return (BugzillaReport) bug; > } > } > >@@ -215,7 +334,7 @@ > */ > public static List<String> getProductList(TaskRepository repository) throws IOException, LoginException, Exception { > >- return BugzillaPlugin.getDefault().getProductConfiguration(repository.getUrl()).getProducts(); >+ return BugzillaPlugin.getDefault().getProductConfiguration(repository).getProducts(); > > // BugzillaQueryPageParser parser = new > // BugzillaQueryPageParser(repository, new NullProgressMonitor()); >@@ -227,6 +346,10 @@ > > } > >+// public static List<String> getValidKeywords(String repositoryURL) { >+// return BugzillaPlugin.getDefault().getProductConfiguration(repositoryURL).getKeywords(); >+// } >+ > // /** > // * Get the attribute values for a new bug > // * >@@ -302,127 +425,426 @@ > // } catch (IOException e) { > // BugzillaPlugin.log(new Status(IStatus.ERROR, > // IBugzillaConstants.PLUGIN_ID, IStatus.ERROR, >- // "Problem closing the stream", e)); >- // } >- // } >- // } >+ // "Problem closing the stream", e)); >+ // } >+ // } >+ // } > > /** > * Adds bug attributes to new bug model and sets defaults > */ >- public static void setupBugAttributes(String serverUrl, NewBugModel model) { >+ public static void setupNewBugAttributes(TaskRepository repository, NewBugzillaReport newReport) { >+ >+ // // order is important >+ // BugReportElement[] newBugElements = { BugReportElement.PRODUCT, >+ // BugReportElement.BUG_STATUS, >+ // BugReportElement.VERSION, >+ // BugReportElement.COMPONENT, >+ // BugReportElement.TARGET_MILESTONE, >+ // BugReportElement.REP_PLATFORM, >+ // BugReportElement.OP_SYS, >+ // BugReportElement.PRIORITY, >+ // BugReportElement.BUG_SEVERITY, >+ // BugReportElement.ASSIGNED_TO, >+ // // NOT USED BugReportElement.CC, >+ // BugReportElement.BUG_FILE_LOC, >+ // //NOT USED BugReportElement.SHORT_DESC, >+ // //NOT USED BugReportElement.LONG_DESC >+ // }; > >-// // order is important >-// BugReportElement[] newBugElements = { BugReportElement.PRODUCT, >-// BugReportElement.BUG_STATUS, >-// BugReportElement.VERSION, >-// BugReportElement.COMPONENT, >-// BugReportElement.TARGET_MILESTONE, >-// BugReportElement.REP_PLATFORM, >-// BugReportElement.OP_SYS, >-// BugReportElement.PRIORITY, >-// BugReportElement.BUG_SEVERITY, >-// BugReportElement.ASSIGNED_TO, >-//// NOT USED BugReportElement.CC, >-// BugReportElement.BUG_FILE_LOC, >-// //NOT USED BugReportElement.SHORT_DESC, >-// //NOT USED BugReportElement.LONG_DESC >-// }; >- >- >- >- >- HashMap<String, Attribute> attributes = new LinkedHashMap<String, Attribute>(); >- >- Attribute a = new Attribute(BugReportElement.PRODUCT.toString()); >- a.setParameterName(BugReportElement.PRODUCT.getKeyString()); >- List<String> optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getProducts(); >+ // HashMap<String, AbstractRepositoryReportAttribute> attributes = new >+ // LinkedHashMap<String, AbstractRepositoryReportAttribute>(); >+ >+ AbstractRepositoryReportAttribute a = new BugzillaReportAttribute(BugzillaReportElement.PRODUCT); >+ List<String> optionValues = BugzillaPlugin.getDefault().getProductConfiguration(repository).getProducts(); > for (String option : optionValues) { > a.addOptionValue(option, option); > } >- a.setValue(model.getProduct()); >- attributes.put(a.getName(), a); >- >- >- a = new Attribute(BugReportElement.BUG_STATUS.toString()); >- a.setParameterName(BugReportElement.BUG_STATUS.getKeyString()); >- optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getStatusValues(); >+ a.setValue(newReport.getProduct()); >+ newReport.addAttribute(BugzillaReportElement.PRODUCT, a); >+ // attributes.put(a.getName(), a); >+ >+ a = new BugzillaReportAttribute(BugzillaReportElement.BUG_STATUS); >+ optionValues = BugzillaPlugin.getDefault().getProductConfiguration(repository).getStatusValues(); > for (String option : optionValues) { > a.addOptionValue(option, option); > } > a.setValue(BUG_STATUS_NEW); >- attributes.put(a.getName(), a); >- >- a = new Attribute(BugReportElement.VERSION.toString()); >- a.setParameterName(BugReportElement.VERSION.getKeyString()); >- optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getVersions(model.getProduct()); >+ newReport.addAttribute(BugzillaReportElement.BUG_STATUS, a); >+ // attributes.put(a.getName(), a); >+ >+ a = new BugzillaReportAttribute(BugzillaReportElement.VERSION); >+ optionValues = BugzillaPlugin.getDefault().getProductConfiguration(repository).getVersions( >+ newReport.getProduct()); > for (String option : optionValues) { > a.addOptionValue(option, option); > } >- a.setValue(optionValues.get(optionValues.size() - 1)); >- attributes.put(a.getName(), a); >- >- a = new Attribute(BugReportElement.COMPONENT.toString()); >- a.setParameterName(BugReportElement.COMPONENT.getKeyString()); >- optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getComponents(model.getProduct()); >- for (String option : optionValues) { >- a.addOptionValue(option, option); >+ if (optionValues != null && optionValues.size() > 0) { >+ a.setValue(optionValues.get(optionValues.size() - 1)); > } >- attributes.put(a.getName(), a); >- >- a = new Attribute(BugReportElement.REP_PLATFORM.toString()); >- a.setParameterName(BugReportElement.REP_PLATFORM.getKeyString()); >- optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPlatforms(); >+ newReport.addAttribute(BugzillaReportElement.VERSION, a); >+ // attributes.put(a.getName(), a); >+ >+ a = new BugzillaReportAttribute(BugzillaReportElement.COMPONENT); >+ optionValues = BugzillaPlugin.getDefault().getProductConfiguration(repository).getComponents( >+ newReport.getProduct()); > for (String option : optionValues) { > a.addOptionValue(option, option); > } >- attributes.put(a.getName(), a); >+ newReport.addAttribute(BugzillaReportElement.COMPONENT, a); > >- a = new Attribute(BugReportElement.OP_SYS.toString()); >- a.setParameterName(BugReportElement.OP_SYS.getKeyString()); >- optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getOSs(); >+ a = new BugzillaReportAttribute(BugzillaReportElement.REP_PLATFORM); >+ optionValues = BugzillaPlugin.getDefault().getProductConfiguration(repository).getPlatforms(); > for (String option : optionValues) { > a.addOptionValue(option, option); > } >- attributes.put(a.getName(), a); >+ newReport.addAttribute(BugzillaReportElement.REP_PLATFORM, a); >+ // attributes.put(a.getName(), a); > >- a = new Attribute(BugReportElement.PRIORITY.toString()); >- a.setParameterName(BugReportElement.PRIORITY.getKeyString()); >- optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPriorities(); >+ a = new BugzillaReportAttribute(BugzillaReportElement.OP_SYS); >+ optionValues = BugzillaPlugin.getDefault().getProductConfiguration(repository).getOSs(); > for (String option : optionValues) { > a.addOptionValue(option, option); > } >- a.setValue(optionValues.get((optionValues.size() / 2))); >- attributes.put(a.getName(), a); >+ newReport.addAttribute(BugzillaReportElement.OP_SYS, a); >+ // attributes.put(a.getName(), a); > >- a = new Attribute(BugReportElement.BUG_SEVERITY.toString()); >- a.setParameterName(BugReportElement.BUG_SEVERITY.getKeyString()); >- optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getSeverities(); >+ a = new BugzillaReportAttribute(BugzillaReportElement.PRIORITY); >+ optionValues = BugzillaPlugin.getDefault().getProductConfiguration(repository).getPriorities(); > for (String option : optionValues) { > a.addOptionValue(option, option); > } > a.setValue(optionValues.get((optionValues.size() / 2))); >- attributes.put(a.getName(), a); >- >- a = new Attribute(BugReportElement.TARGET_MILESTONE.toString()); >- a.setParameterName(BugReportElement.TARGET_MILESTONE.getKeyString()); >- optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getTargetMilestones(model.getProduct()); >+ newReport.addAttribute(BugzillaReportElement.PRIORITY, a); >+ // attributes.put(a.getName(), a); >+ >+ a = new BugzillaReportAttribute(BugzillaReportElement.BUG_SEVERITY); >+ optionValues = BugzillaPlugin.getDefault().getProductConfiguration(repository).getSeverities(); > for (String option : optionValues) { > a.addOptionValue(option, option); > } >- attributes.put(a.getName(), a); >+ a.setValue(optionValues.get((optionValues.size() / 2))); >+ newReport.addAttribute(BugzillaReportElement.BUG_SEVERITY, a); >+ // attributes.put(a.getName(), a); >+ >+ // a = new >+ // BugzillaReportAttribute(BugzillaReportElement.TARGET_MILESTONE); >+ // optionValues = >+ // BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getTargetMilestones( >+ // newReport.getProduct()); >+ // for (String option : optionValues) { >+ // a.addOptionValue(option, option); >+ // } >+ // if(optionValues.size() > 0) { >+ // // new bug posts will fail if target_milestone element is included >+ // // and there are no milestones on the server >+ // newReport.addAttribute(BugzillaReportElement.TARGET_MILESTONE, a); >+ // } > >- a = new Attribute(BugReportElement.ASSIGNED_TO.toString()); >- a.setParameterName(BugReportElement.ASSIGNED_TO.getKeyString()); >+ a = new BugzillaReportAttribute(BugzillaReportElement.ASSIGNED_TO); > a.setValue(""); >- attributes.put(a.getName(), a); >- >- a = new Attribute(BugReportElement.BUG_FILE_LOC.toString()); >- a.setParameterName(BugReportElement.BUG_FILE_LOC.getKeyString()); >+ newReport.addAttribute(BugzillaReportElement.ASSIGNED_TO, a); >+ // attributes.put(a.getName(), a); >+ >+ a = new BugzillaReportAttribute(BugzillaReportElement.BUG_FILE_LOC); > a.setValue("http://"); >- attributes.put(a.getName(), a); >- >- model.attributes = attributes; >+ a.setHidden(false); >+ newReport.addAttribute(BugzillaReportElement.BUG_FILE_LOC, a); >+ // attributes.put(a.getName(), a); >+ >+ // newReport.attributes = attributes; >+ } >+ >+ // /** >+ // * Adds bug attributes to new bug model and sets defaults >+ // */ >+ // public static void setupExistingBugAttributes(String serverUrl, BugReport >+ // existingReport) { >+ // >+ // // // order is important >+ // // BugReportElement[] newBugElements = { BugReportElement.PRODUCT, >+ // // BugReportElement.BUG_STATUS, >+ // // BugReportElement.VERSION, >+ // // BugReportElement.COMPONENT, >+ // // BugReportElement.TARGET_MILESTONE, >+ // // BugReportElement.REP_PLATFORM, >+ // // BugReportElement.OP_SYS, >+ // // BugReportElement.PRIORITY, >+ // // BugReportElement.BUG_SEVERITY, >+ // // BugReportElement.ASSIGNED_TO, >+ // // // NOT USED BugReportElement.CC, >+ // // BugReportElement.BUG_FILE_LOC, >+ // // //NOT USED BugReportElement.SHORT_DESC, >+ // // //NOT USED BugReportElement.LONG_DESC >+ // // }; >+ // >+ // // HashMap<String, AbstractRepositoryReportAttribute> attributes = new >+ // // LinkedHashMap<String, AbstractRepositoryReportAttribute>(); >+ // List<String> optionValues; >+ // AbstractRepositoryReportAttribute a = >+ // existingReport.getAttribute(BugzillaReportElement.PRODUCT); >+ // if (a != null) { >+ // optionValues = >+ // BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getProducts(); >+ // for (String option : optionValues) { >+ // a.addOptionValue(option, option); >+ // } >+ // } >+ // // existingReport.addAttribute(BugzillaReportElement.PRODUCT, a); >+ // >+ // a = existingReport.getAttribute(BugzillaReportElement.BUG_STATUS); >+ // if (a != null) { >+ // optionValues = >+ // BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getStatusValues(); >+ // for (String option : optionValues) { >+ // a.addOptionValue(option, option); >+ // } >+ // } >+ // // existingReport.addAttribute(BugzillaReportElement.BUG_STATUS, a); >+ // >+ // a = existingReport.getAttribute(BugzillaReportElement.VERSION); >+ // if (a != null) { >+ // optionValues = >+ // BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getVersions( >+ // existingReport.getProduct()); >+ // for (String option : optionValues) { >+ // a.addOptionValue(option, option); >+ // } >+ // } >+ // // existingReport.addAttribute(BugzillaReportElement.VERSION, a); >+ // >+ // a = existingReport.getAttribute(BugzillaReportElement.COMPONENT); >+ // if (a != null) { >+ // optionValues = >+ // BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getComponents( >+ // existingReport.getProduct()); >+ // for (String option : optionValues) { >+ // a.addOptionValue(option, option); >+ // } >+ // } >+ // // existingReport.addAttribute(BugzillaReportElement.COMPONENT, a); >+ // >+ // a = existingReport.getAttribute(BugzillaReportElement.REP_PLATFORM); >+ // if (a != null) { >+ // optionValues = >+ // BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPlatforms(); >+ // for (String option : optionValues) { >+ // a.addOptionValue(option, option); >+ // } >+ // } >+ // // existingReport.addAttribute(BugzillaReportElement.REP_PLATFORM, a); >+ // >+ // a = existingReport.getAttribute(BugzillaReportElement.OP_SYS); >+ // if (a != null) { >+ // optionValues = >+ // BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getOSs(); >+ // for (String option : optionValues) { >+ // a.addOptionValue(option, option); >+ // } >+ // } >+ // // existingReport.addAttribute(BugzillaReportElement.OP_SYS, a); >+ // >+ // a = existingReport.getAttribute(BugzillaReportElement.PRIORITY); >+ // if (a != null) { >+ // optionValues = >+ // BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPriorities(); >+ // for (String option : optionValues) { >+ // a.addOptionValue(option, option); >+ // } >+ // } >+ // // existingReport.addAttribute(BugzillaReportElement.PRIORITY, a); >+ // >+ // a = existingReport.getAttribute(BugzillaReportElement.BUG_SEVERITY); >+ // if (a != null) { >+ // optionValues = >+ // BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getSeverities(); >+ // for (String option : optionValues) { >+ // a.addOptionValue(option, option); >+ // } >+ // } >+ // // existingReport.addAttribute(BugzillaReportElement.BUG_SEVERITY, a); >+ // >+ // a = existingReport.getAttribute(BugzillaReportElement.TARGET_MILESTONE); >+ // if (a != null) { >+ // optionValues = >+ // BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getTargetMilestones( >+ // existingReport.getProduct()); >+ // for (String option : optionValues) { >+ // a.addOptionValue(option, option); >+ // } >+ // } >+ // // existingReport.addAttribute(BugzillaReportElement.TARGET_MILESTONE, >+ // // a); >+ // >+ // // a = new BugzillaReportAttribute(BugzillaReportElement.ASSIGNED_TO); >+ // // existingReport.addAttribute(BugzillaReportElement.ASSIGNED_TO, a); >+ // // >+ // // a = new BugzillaReportAttribute(BugzillaReportElement.BUG_FILE_LOC); >+ // // existingReport.addAttribute(BugzillaReportElement.BUG_FILE_LOC, a); >+ // >+ // // Add fields that may not be present in xml but required for ui and >+ // // submission. NOTE: Perhaps the bug reports should be set up with all >+ // // valid attributes >+ // // and then passed to the parser to populate the appropriate fields >+ // // rather than >+ // >+ // a = existingReport.getAttribute(BugzillaReportElement.CC); >+ // if (a == null) { >+ // existingReport >+ // .addAttribute(BugzillaReportElement.CC, new >+ // BugzillaReportAttribute(BugzillaReportElement.CC)); >+ // } >+ // a = existingReport.getAttribute(BugzillaReportElement.RESOLUTION); >+ // if (a == null) { >+ // existingReport.addAttribute(BugzillaReportElement.RESOLUTION, new >+ // BugzillaReportAttribute( >+ // BugzillaReportElement.RESOLUTION)); >+ // } >+ // a = existingReport.getAttribute(BugzillaReportElement.BUG_FILE_LOC); >+ // if (a == null) { >+ // existingReport.addAttribute(BugzillaReportElement.BUG_FILE_LOC, new >+ // BugzillaReportAttribute( >+ // BugzillaReportElement.BUG_FILE_LOC)); >+ // } >+ // a = existingReport.getAttribute(BugzillaReportElement.NEWCC); >+ // if (a == null) { >+ // existingReport.addAttribute(BugzillaReportElement.NEWCC, new >+ // BugzillaReportAttribute( >+ // BugzillaReportElement.NEWCC)); >+ // } >+ // >+ // // Special hidden fields required when existing bug is submitted to >+ // // bugzilla >+ // a = existingReport.getAttribute(BugzillaReportElement.LONGDESCLENGTH); >+ // if (a == null) { >+ // a = new BugzillaReportAttribute(BugzillaReportElement.LONGDESCLENGTH); >+ // a.setValue("" + existingReport.getComments().size()); >+ // existingReport.addAttribute(BugzillaReportElement.LONGDESCLENGTH, a); >+ // } >+ // >+ // } >+ >+ public static void setupExistingBugAttributes(String serverUrl, BugzillaReport existingReport) { >+ // ordered list of elements as they appear in UI >+ // and additional elements that may not appear in the incoming xml >+ // stream but need to be present for bug submission >+ BugzillaReportElement[] reportElements = { BugzillaReportElement.BUG_STATUS, BugzillaReportElement.RESOLUTION, >+ BugzillaReportElement.BUG_ID, BugzillaReportElement.REP_PLATFORM, BugzillaReportElement.PRODUCT, >+ BugzillaReportElement.OP_SYS, BugzillaReportElement.COMPONENT, BugzillaReportElement.VERSION, >+ BugzillaReportElement.PRIORITY, BugzillaReportElement.BUG_SEVERITY, BugzillaReportElement.ASSIGNED_TO, >+ BugzillaReportElement.TARGET_MILESTONE, BugzillaReportElement.REPORTER, BugzillaReportElement.DEPENDSON, BugzillaReportElement.BLOCKED, >+ BugzillaReportElement.BUG_FILE_LOC, BugzillaReportElement.NEWCC, BugzillaReportElement.KEYWORDS}; >+ >+ for (BugzillaReportElement element : reportElements) { >+ AbstractRepositoryReportAttribute reportAttribute = new BugzillaReportAttribute(element); >+ existingReport.addAttribute(element, reportAttribute); >+ } >+ } >+ >+ private static void updateBugAttributeOptions(TaskRepository repository, BugzillaReport existingReport) { >+ String product = existingReport.getAttributeValue(BugzillaReportElement.PRODUCT); >+ for (AbstractRepositoryReportAttribute attribute : existingReport.getAttributes()) { >+ BugzillaReportElement element = BugzillaReportElement.valueOf(attribute.getID().trim().toUpperCase()); >+ attribute.clearOptions(); >+ List<String> optionValues = BugzillaPlugin.getDefault().getProductConfiguration(repository).getOptionValues( >+ element, product); >+ if (element == BugzillaReportElement.TARGET_MILESTONE && optionValues.isEmpty()) { >+ existingReport.removeAttribute(BugzillaReportElement.TARGET_MILESTONE); >+ continue; >+ } >+ for (String option : optionValues) { >+ attribute.addOptionValue(option, option); >+ } >+ } >+ >+ } >+ >+ public static void addValidOperations(BugzillaReport bugReport) { >+ BUGZILLA_REPORT_STATUS status = BUGZILLA_REPORT_STATUS.valueOf(bugReport.getStatus()); >+ switch (status) { >+ case UNCONFIRMED: >+ case REOPENED: >+ case NEW: >+ addOperation(bugReport, BUGZILLA_OPERATION.none); >+ addOperation(bugReport, BUGZILLA_OPERATION.accept); >+ addOperation(bugReport, BUGZILLA_OPERATION.resolve); >+ addOperation(bugReport, BUGZILLA_OPERATION.duplicate); >+ addOperation(bugReport, BUGZILLA_OPERATION.reassign); >+ addOperation(bugReport, BUGZILLA_OPERATION.reassignbycomponent); >+ break; >+ case ASSIGNED: >+ addOperation(bugReport, BUGZILLA_OPERATION.none); >+ addOperation(bugReport, BUGZILLA_OPERATION.resolve); >+ addOperation(bugReport, BUGZILLA_OPERATION.duplicate); >+ addOperation(bugReport, BUGZILLA_OPERATION.reassign); >+ addOperation(bugReport, BUGZILLA_OPERATION.reassignbycomponent); >+ break; >+ case RESOLVED: >+ addOperation(bugReport, BUGZILLA_OPERATION.none); >+ addOperation(bugReport, BUGZILLA_OPERATION.reopen); >+ addOperation(bugReport, BUGZILLA_OPERATION.verify); >+ addOperation(bugReport, BUGZILLA_OPERATION.close); >+ break; >+ case CLOSED: >+ addOperation(bugReport, BUGZILLA_OPERATION.none); >+ addOperation(bugReport, BUGZILLA_OPERATION.reopen); >+ break; >+ case VERIFIED: >+ addOperation(bugReport, BUGZILLA_OPERATION.none); >+ addOperation(bugReport, BUGZILLA_OPERATION.reopen); >+ addOperation(bugReport, BUGZILLA_OPERATION.close); >+ } >+ } >+ >+ public static void addOperation(BugzillaReport bugReport, BUGZILLA_OPERATION opcode) { >+ Operation newOperation = null; >+ switch (opcode) { >+ case none: >+ newOperation = new Operation(opcode.toString(), "Leave as " + bugReport.getStatus() + " " >+ + bugReport.getResolution()); >+ newOperation.setChecked(true); >+ break; >+ case accept: >+ newOperation = new Operation(opcode.toString(), OPERATION_LABEL_ACCEPT); >+ break; >+ case resolve: >+ newOperation = new Operation(opcode.toString(), OPERATION_LABEL_RESOLVE); >+ newOperation.setUpOptions(OPERATION_OPTION_RESOLUTION); >+ for (BUGZILLA_RESOLUTION resolution: BUGZILLA_RESOLUTION.values()) { >+ newOperation.addOption(resolution.toString(), resolution.toString()); >+ } >+ break; >+ case duplicate: >+ newOperation = new Operation(opcode.toString(), OPERATION_LABEL_DUPLICATE); >+ newOperation.setInputName(OPERATION_INPUT_DUP_ID); >+ newOperation.setInputValue(""); >+ break; >+ case reassign: >+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository( >+ BugzillaPlugin.REPOSITORY_KIND, bugReport.getRepositoryUrl()); >+ String localUser = repository.getUserName(); >+ newOperation = new Operation(opcode.toString(), OPERATION_LABEL_REASSIGN); >+ newOperation.setInputName(OPERATION_INPUT_ASSIGNED_TO); >+ newOperation.setInputValue(localUser); >+ break; >+ case reassignbycomponent: >+ newOperation = new Operation(opcode.toString(), OPERATION_LABEL_REASSIGN_DEFAULT); >+ break; >+ case reopen: >+ newOperation = new Operation(opcode.toString(), OPERATION_LABEL_REOPEN); >+ break; >+ case verify: >+ newOperation = new Operation(opcode.toString(), OPERATION_LABEL_VERIFY); >+ break; >+ case close: >+ newOperation = new Operation(opcode.toString(), OPERATION_LABEL_CLOSE); >+ break; >+ default: >+ MylarStatusHandler.log("Unknown bugzilla operation code recieved", BugzillaRepositoryUtil.class); >+ } >+ if (newOperation != null) { >+ bugReport.addOperation(newOperation); >+ } > } > > public static String getBugUrl(String repositoryUrl, int id) { >@@ -430,12 +852,7 @@ > BugzillaPlugin.REPOSITORY_KIND, repositoryUrl); > String url = repository.getUrl() + POST_ARGS_SHOW_BUG + id; > try { >- if (repository.hasCredentials()) { >- url += "&" + POST_ARGS_LOGIN >- + URLEncoder.encode(repository.getUserName(), BugzillaPlugin.ENCODING_UTF_8) >- + POST_ARGS_PASSWORD >- + URLEncoder.encode(repository.getPassword(), BugzillaPlugin.ENCODING_UTF_8); >- } >+ url = addCredentials(repository, url); > } catch (UnsupportedEncodingException e) { > return ""; > } >@@ -503,7 +920,7 @@ > // if (!parser.wasSuccessful()) > // return; > >- RepositoryConfiguration config = ServerConfigurationFactory.getInstance().getConfiguration(repositoryUrl); >+ RepositoryConfiguration config = RepositoryConfigurationFactory.getInstance().getConfiguration(repository); > > // get the preferences store so that we can change the data in it > IPreferenceStore prefs = BugzillaPlugin.getDefault().getPreferenceStore(); >@@ -574,12 +991,7 @@ > FileOutputStream outStream = null; > try { > String url = repository.getUrl() + POST_ARGS_ATTACHMENT_DOWNLOAD + id; >- if (repository.hasCredentials()) { >- url += "&" + POST_ARGS_LOGIN >- + URLEncoder.encode(repository.getUserName(), BugzillaPlugin.ENCODING_UTF_8) >- + POST_ARGS_PASSWORD >- + URLEncoder.encode(repository.getPassword(), BugzillaPlugin.ENCODING_UTF_8); >- } >+ url = addCredentials(repository, url); > URL downloadUrl = new URL(url); > URLConnection connection = BugzillaPlugin.getDefault().getUrlConnection(downloadUrl); > if (connection != null) { >@@ -744,6 +1156,26 @@ > return uploadResult; > } > >+ >+ public static String getCharsetFromString(String string) { >+ int charsetStartIndex = string.indexOf(ATTR_CHARSET); >+ if (charsetStartIndex != -1) { >+ int charsetEndIndex = string.indexOf("\"", charsetStartIndex); // TODO: >+ // could >+ // be >+ // space >+ // after? >+ if (charsetEndIndex == -1) { >+ charsetEndIndex = string.length(); >+ } >+ String charsetString = string.substring(charsetStartIndex + 8, charsetEndIndex); >+ if (Charset.availableCharsets().containsKey(charsetString)) { >+ return charsetString; >+ } >+ } >+ return null; >+ } >+ > } > > /** >Index: src/org/eclipse/mylar/internal/bugzilla/core/BugzillaPlugin.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/BugzillaPlugin.java,v >retrieving revision 1.13 >diff -u -r1.13 BugzillaPlugin.java >--- src/org/eclipse/mylar/internal/bugzilla/core/BugzillaPlugin.java 25 Apr 2006 01:40:51 -0000 1.13 >+++ src/org/eclipse/mylar/internal/bugzilla/core/BugzillaPlugin.java 8 May 2006 23:07:23 -0000 >@@ -35,11 +35,11 @@ > import org.eclipse.jface.dialogs.ErrorDialog; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.mylar.bugzilla.core.IBugzillaBug; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.internal.bugzilla.core.internal.FavoritesFile; > import org.eclipse.mylar.internal.bugzilla.core.internal.OfflineReportsFile; > import org.eclipse.mylar.internal.bugzilla.core.internal.RepositoryConfiguration; >-import org.eclipse.mylar.internal.bugzilla.core.internal.ServerConfigurationFactory; >+import org.eclipse.mylar.internal.bugzilla.core.internal.RepositoryConfigurationFactory; > import org.eclipse.mylar.internal.bugzilla.core.search.IBugzillaResultEditorMatchAdapter; > import org.eclipse.mylar.internal.core.util.MylarStatusHandler; > import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin; >@@ -105,21 +105,21 @@ > Authenticator.setDefault(authenticator); > > // Removed since not repository specific >- //setDefaultQueryOptions(); >+ // setDefaultQueryOptions(); > > readFavoritesFile(); > readOfflineReportsFile(); > >-// final Set<TaskRepository> repositories = MylarTaskListPlugin.getRepositoryManager().getRepositories( >-// REPOSITORY_KIND); >-// for (TaskRepository repository : repositories) { >-// readCachedProductConfiguration(repository.getUrl()); >-// } >- >+ // final Set<TaskRepository> repositories = >+ // MylarTaskListPlugin.getRepositoryManager().getRepositories( >+ // REPOSITORY_KIND); >+ // for (TaskRepository repository : repositories) { >+ // readCachedProductConfiguration(repository.getUrl()); >+ // } >+ > migrateOldAuthenticationData(); > } > >- > @SuppressWarnings("unchecked") > private void migrateOldAuthenticationData() { > String OLD_PREF_SERVER = "BUGZILLA_SERVER"; >@@ -141,14 +141,15 @@ > password = pwd; > } > TaskRepository repository; >-// try { >- repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, serverUrl); >- repository.setAuthenticationCredentials(user, password); >- MylarTaskListPlugin.getRepositoryManager().addRepository(repository); >- BugzillaPlugin.getDefault().getPreferenceStore().setValue(OLD_PREF_SERVER, ""); >-// } catch (MalformedURLException e) { >-// MylarStatusHandler.fail(e, "could not create default repository", true); >-// } >+ // try { >+ repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, serverUrl); >+ repository.setAuthenticationCredentials(user, password); >+ MylarTaskListPlugin.getRepositoryManager().addRepository(repository); >+ BugzillaPlugin.getDefault().getPreferenceStore().setValue(OLD_PREF_SERVER, ""); >+ // } catch (MalformedURLException e) { >+ // MylarStatusHandler.fail(e, "could not create default repository", >+ // true); >+ // } > try { > // reset the authorization > Platform.addAuthorizationInfo(BugzillaPreferencePage.FAKE_URL, "Bugzilla", >@@ -188,24 +189,27 @@ > BugzillaPreferencePage.initDefaults(store); > } > >-// /** >-// * // * Get the name of the bugzilla server // * // * >-// * >-// * @return A string containing the prefered name of the bugzilla server // >-// */ >-// // public String getServerName() { >-// // return >-// // plugin.getPreferenceStore().getString(IBugzillaConstants.BUGZILLA_SERVER); >-// // } >-// public boolean isServerCompatability218() { >-// return IBugzillaConstants.SERVER_218.equals(getPreferenceStore().getString(IBugzillaConstants.SERVER_VERSION)) >-// || IBugzillaConstants.SERVER_220.equals(getPreferenceStore().getString( >-// IBugzillaConstants.SERVER_VERSION)); >-// } >-// >-// public boolean isServerCompatability220() { >-// return IBugzillaConstants.SERVER_220.equals(getPreferenceStore().getString(IBugzillaConstants.SERVER_VERSION)); >-// } >+ // /** >+ // * // * Get the name of the bugzilla server // * // * >+ // * >+ // * @return A string containing the prefered name of the bugzilla server // >+ // */ >+ // // public String getServerName() { >+ // // return >+ // // >+ // plugin.getPreferenceStore().getString(IBugzillaConstants.BUGZILLA_SERVER); >+ // // } >+ // public boolean isServerCompatability218() { >+ // return >+ // IBugzillaConstants.SERVER_218.equals(getPreferenceStore().getString(IBugzillaConstants.SERVER_VERSION)) >+ // || IBugzillaConstants.SERVER_220.equals(getPreferenceStore().getString( >+ // IBugzillaConstants.SERVER_VERSION)); >+ // } >+ // >+ // public boolean isServerCompatability220() { >+ // return >+ // IBugzillaConstants.SERVER_220.equals(getPreferenceStore().getString(IBugzillaConstants.SERVER_VERSION)); >+ // } > > /** > * Get the most recent query key for the preferences >@@ -216,22 +220,35 @@ > return plugin.getPreferenceStore().getString(IBugzillaConstants.MOST_RECENT_QUERY); > } > >- public RepositoryConfiguration getProductConfiguration(String serverUrl) { >- if(! repositoryConfigurations.containsKey(serverUrl)) { >+ public RepositoryConfiguration getProductConfiguration(TaskRepository repository) { >+ if (!repositoryConfigurations.containsKey(repository.getUrl())) { > try { >- repositoryConfigurations.put(serverUrl, ServerConfigurationFactory.getInstance().getConfiguration( >- serverUrl)); >+ repositoryConfigurations.put(repository.getUrl(), RepositoryConfigurationFactory.getInstance().getConfiguration( >+ repository)); > } catch (IOException e) { >- MessageDialog >- .openInformation( >- null, >- "Retrieval of Bugzilla Configuration", "Bugzilla configuration retrieval failed."); >+ MessageDialog.openInformation(null, "Retrieval of Bugzilla Configuration", >+ "Bugzilla configuration retrieval failed."); > } > } >- >- return repositoryConfigurations.get(serverUrl); >+ >+ return repositoryConfigurations.get(repository.getUrl()); > } > >+ >+// public RepositoryConfiguration getProductConfiguration(String serverUrl) { >+// if (!repositoryConfigurations.containsKey(serverUrl)) { >+// try { >+// repositoryConfigurations.put(serverUrl, RepositoryConfigurationFactory.getInstance().getConfiguration( >+// serverUrl)); >+// } catch (IOException e) { >+// MessageDialog.openInformation(null, "Retrieval of Bugzilla Configuration", >+// "Bugzilla configuration retrieval failed."); >+// } >+// } >+// >+// return repositoryConfigurations.get(serverUrl); >+// } >+ > protected void setProductConfiguration(String serverUrl, RepositoryConfiguration repositoryConfiguration) { > repositoryConfigurations.put(serverUrl, repositoryConfiguration); > // this.productConfiguration = productConfiguration; >@@ -262,14 +279,18 @@ > try { > offlineReportsFile = new OfflineReportsFile(offlineReportsPath.toFile()); > } catch (Exception e) { >- MylarStatusHandler.fail(e, "could not restore offline Bugzilla reports file", true); >-// logAndShowExceptionDetailsDialog(e, "occurred while restoring saved offline Bugzilla reports.", >-// "Bugzilla Offline Reports Error"); >- offlineReportsPath.toFile().delete(); >- try { >- offlineReportsFile = new OfflineReportsFile(offlineReportsPath.toFile()); >- } catch (IOException e1) { >- MylarStatusHandler.fail(e, "could not reset offline Bugzilla reports file", true); >+ MylarStatusHandler.fail(e, "could not restore offline Bugzilla reports file, creating new one", false); >+ // logAndShowExceptionDetailsDialog(e, "occurred while restoring >+ // saved offline Bugzilla reports.", >+ // "Bugzilla Offline Reports Error"); >+ if (offlineReportsPath.toFile().delete()) { >+ try { >+ offlineReportsFile = new OfflineReportsFile(offlineReportsPath.toFile()); >+ } catch (Exception e1) { >+ MylarStatusHandler.fail(e, "could not reset offline Bugzilla reports file", true); >+ } >+ } else { >+ MylarStatusHandler.fail(null, "reset of Bugzilla offline reports file failed", true); > } > } > } >@@ -292,38 +313,42 @@ > return configFile; > } > >-// /** >-// * Reads cached product configuration and stores it in the >-// * <code>productConfiguration</code> field. >-// * >-// * TODO remove this? >-// */ >-// private void readCachedProductConfiguration(String serverUrl) { >-// IPath configFile = getProductConfigurationCachePath(serverUrl); >-// >-// try { >-// productConfigurations.put(serverUrl, ServerConfigurationFactory.getInstance().readConfiguration( >-// configFile.toFile())); >-// } catch (IOException ex) { >-// try { >-// log(ex); >-// productConfigurations.put(serverUrl, ServerConfigurationFactory.getInstance().getConfiguration( >-// serverUrl)); >-// } catch (IOException e) { >-// log(e); >-// MessageDialog >-// .openInformation( >-// null, >-// "Bugzilla product attributes check", >-// "An error occurred while restoring saved Bugzilla product attributes: \n\n" >-// + ex.getMessage() >-// + "\n\nUpdating them from the server also caused an error:\n\n" >-// + e.getMessage() >-// + "\n\nCheck the server URL in Bugzila preferences.\n" >-// + "Offline submission of new bugs will be disabled until valid product attributes have been loaded."); >-// } >-// } >-// } >+ // /** >+ // * Reads cached product configuration and stores it in the >+ // * <code>productConfiguration</code> field. >+ // * >+ // * TODO remove this? >+ // */ >+ // private void readCachedProductConfiguration(String serverUrl) { >+ // IPath configFile = getProductConfigurationCachePath(serverUrl); >+ // >+ // try { >+ // productConfigurations.put(serverUrl, >+ // ServerConfigurationFactory.getInstance().readConfiguration( >+ // configFile.toFile())); >+ // } catch (IOException ex) { >+ // try { >+ // log(ex); >+ // productConfigurations.put(serverUrl, >+ // ServerConfigurationFactory.getInstance().getConfiguration( >+ // serverUrl)); >+ // } catch (IOException e) { >+ // log(e); >+ // MessageDialog >+ // .openInformation( >+ // null, >+ // "Bugzilla product attributes check", >+ // "An error occurred while restoring saved Bugzilla product attributes: >+ // \n\n" >+ // + ex.getMessage() >+ // + "\n\nUpdating them from the server also caused an error:\n\n" >+ // + e.getMessage() >+ // + "\n\nCheck the server URL in Bugzila preferences.\n" >+ // + "Offline submission of new bugs will be disabled until valid product >+ // attributes have been loaded."); >+ // } >+ // } >+ // } > > /** > * Returns the path to the file cacheing the product configuration. >@@ -391,7 +416,7 @@ > /** > * @return a list of the BugReports saved offline. > */ >- public List<IBugzillaBug> getSavedBugReports() { >+ public List<BugzillaReport> getSavedBugReports() { > return offlineReportsFile.elements(); > } > >@@ -432,42 +457,50 @@ > return getPreferenceStore().getInt(IBugzillaConstants.MAX_RESULTS); > } > >-// private void setDefaultQueryOptions() { >-// // get the preferences store for the bugzilla preferences >-// IPreferenceStore prefs = getPreferenceStore(); >-// >-// prefs.setDefault(IBugzillaConstants.VALUES_STATUS, BugzillaRepositoryUtil >-// .queryOptionsToString(IBugzillaConstants.DEFAULT_STATUS_VALUES)); >-// >-// prefs.setDefault(IBugzillaConstants.VALUSE_STATUS_PRESELECTED, BugzillaRepositoryUtil >-// .queryOptionsToString(IBugzillaConstants.DEFAULT_PRESELECTED_STATUS_VALUES)); >-// >-// prefs.setDefault(IBugzillaConstants.VALUES_RESOLUTION, BugzillaRepositoryUtil >-// .queryOptionsToString(IBugzillaConstants.DEFAULT_RESOLUTION_VALUES)); >-// >-// prefs.setDefault(IBugzillaConstants.VALUES_SEVERITY, BugzillaRepositoryUtil >-// .queryOptionsToString(IBugzillaConstants.DEFAULT_SEVERITY_VALUES)); >-// >-// prefs.setDefault(IBugzillaConstants.VALUES_PRIORITY, BugzillaRepositoryUtil >-// .queryOptionsToString(IBugzillaConstants.DEFAULT_PRIORITY_VALUES)); >-// >-// prefs.setDefault(IBugzillaConstants.VALUES_HARDWARE, BugzillaRepositoryUtil >-// .queryOptionsToString(IBugzillaConstants.DEFAULT_HARDWARE_VALUES)); >-// >-// prefs.setDefault(IBugzillaConstants.VALUES_OS, BugzillaRepositoryUtil >-// .queryOptionsToString(IBugzillaConstants.DEFAULT_OS_VALUES)); >-// >-// prefs.setDefault(IBugzillaConstants.VALUES_PRODUCT, BugzillaRepositoryUtil >-// .queryOptionsToString(IBugzillaConstants.DEFAULT_PRODUCT_VALUES)); >-// >-// prefs.setDefault(IBugzillaConstants.VALUES_COMPONENT, BugzillaRepositoryUtil >-// .queryOptionsToString(IBugzillaConstants.DEFAULT_COMPONENT_VALUES)); >-// >-// prefs.setDefault(IBugzillaConstants.VALUES_VERSION, BugzillaRepositoryUtil >-// .queryOptionsToString(IBugzillaConstants.DEFAULT_VERSION_VALUES)); >-// >-// prefs.setDefault(IBugzillaConstants.VALUES_TARGET, BugzillaRepositoryUtil >-// .queryOptionsToString(IBugzillaConstants.DEFAULT_TARGET_VALUES)); >-// } >- >+ // private void setDefaultQueryOptions() { >+ // // get the preferences store for the bugzilla preferences >+ // IPreferenceStore prefs = getPreferenceStore(); >+ // >+ // prefs.setDefault(IBugzillaConstants.VALUES_STATUS, BugzillaRepositoryUtil >+ // .queryOptionsToString(IBugzillaConstants.DEFAULT_STATUS_VALUES)); >+ // >+ // prefs.setDefault(IBugzillaConstants.VALUSE_STATUS_PRESELECTED, >+ // BugzillaRepositoryUtil >+ // .queryOptionsToString(IBugzillaConstants.DEFAULT_PRESELECTED_STATUS_VALUES)); >+ // >+ // prefs.setDefault(IBugzillaConstants.VALUES_RESOLUTION, >+ // BugzillaRepositoryUtil >+ // .queryOptionsToString(IBugzillaConstants.DEFAULT_RESOLUTION_VALUES)); >+ // >+ // prefs.setDefault(IBugzillaConstants.VALUES_SEVERITY, >+ // BugzillaRepositoryUtil >+ // .queryOptionsToString(IBugzillaConstants.DEFAULT_SEVERITY_VALUES)); >+ // >+ // prefs.setDefault(IBugzillaConstants.VALUES_PRIORITY, >+ // BugzillaRepositoryUtil >+ // .queryOptionsToString(IBugzillaConstants.DEFAULT_PRIORITY_VALUES)); >+ // >+ // prefs.setDefault(IBugzillaConstants.VALUES_HARDWARE, >+ // BugzillaRepositoryUtil >+ // .queryOptionsToString(IBugzillaConstants.DEFAULT_HARDWARE_VALUES)); >+ // >+ // prefs.setDefault(IBugzillaConstants.VALUES_OS, BugzillaRepositoryUtil >+ // .queryOptionsToString(IBugzillaConstants.DEFAULT_OS_VALUES)); >+ // >+ // prefs.setDefault(IBugzillaConstants.VALUES_PRODUCT, >+ // BugzillaRepositoryUtil >+ // .queryOptionsToString(IBugzillaConstants.DEFAULT_PRODUCT_VALUES)); >+ // >+ // prefs.setDefault(IBugzillaConstants.VALUES_COMPONENT, >+ // BugzillaRepositoryUtil >+ // .queryOptionsToString(IBugzillaConstants.DEFAULT_COMPONENT_VALUES)); >+ // >+ // prefs.setDefault(IBugzillaConstants.VALUES_VERSION, >+ // BugzillaRepositoryUtil >+ // .queryOptionsToString(IBugzillaConstants.DEFAULT_VERSION_VALUES)); >+ // >+ // prefs.setDefault(IBugzillaConstants.VALUES_TARGET, BugzillaRepositoryUtil >+ // .queryOptionsToString(IBugzillaConstants.DEFAULT_TARGET_VALUES)); >+ // } >+ > } >Index: src/org/eclipse/mylar/internal/bugzilla/core/BugzillaReportSubmitForm.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/BugzillaReportSubmitForm.java,v >retrieving revision 1.14 >diff -u -r1.14 BugzillaReportSubmitForm.java >--- src/org/eclipse/mylar/internal/bugzilla/core/BugzillaReportSubmitForm.java 28 Apr 2006 20:41:44 -0000 1.14 >+++ src/org/eclipse/mylar/internal/bugzilla/core/BugzillaReportSubmitForm.java 8 May 2006 23:07:23 -0000 >@@ -32,15 +32,15 @@ > > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReportAttribute; > import org.eclipse.mylar.bugzilla.core.Operation; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants.BugzillaServerVersion; >-import org.eclipse.mylar.internal.bugzilla.core.internal.BugReportElement; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; > import org.eclipse.mylar.internal.bugzilla.core.internal.HtmlStreamTokenizer; > import org.eclipse.mylar.internal.bugzilla.core.internal.HtmlTag; > import org.eclipse.mylar.internal.bugzilla.core.internal.HtmlStreamTokenizer.Token; >-import org.eclipse.mylar.internal.core.util.MylarStatusHandler; > import org.eclipse.mylar.provisional.tasklist.TaskRepository; > > /** >@@ -57,6 +57,8 @@ > > // private static final String KEY_PRODUCT = "product"; > >+ private static final String KEY_ID = "id"; >+ > private static final String VAL_TRUE = "true"; > > private static final String KEY_REMOVECC = "removecc"; >@@ -71,8 +73,6 @@ > > private static final String METHOD_POST = "POST"; > >- private static final String KEY_NEWCC = "newcc"; >- > private static final String KEY_BUGZILLA_PASSWORD = "Bugzilla_password"; > > private static final String KEY_BUGZILLA_LOGIN = "Bugzilla_login"; >@@ -95,8 +95,6 @@ > > private static final String KEY_SHORT_DESC = "short_desc"; > >- private static final String KEY_ASSIGNED_TO = "Assigned To"; >- > // private static final String KEY_ASSIGN_TO = "Assign To"; > // > // private static final String KEY_URL = "URL"; >@@ -209,7 +207,7 @@ > // return bugzillaReportSubmitForm; > // } > >- public static BugzillaReportSubmitForm makeNewBugPost(TaskRepository repository, NewBugModel model) { >+ public static BugzillaReportSubmitForm makeNewBugPost(TaskRepository repository, NewBugzillaReport model) { > BugzillaReportSubmitForm form = new BugzillaReportSubmitForm(); > form.setPrefix(BugzillaReportSubmitForm.FORM_PREFIX_BUG_218); > form.setPrefix2(BugzillaReportSubmitForm.FORM_PREFIX_BUG_220); >@@ -220,10 +218,11 @@ > setURL(form, repository, POST_BUG_CGI); > // go through all of the attributes and add them to > // the bug post >- Iterator<Attribute> itr = model.getAttributes().iterator(); >+ Iterator<AbstractRepositoryReportAttribute> itr = model.getAttributes().iterator(); > while (itr.hasNext()) { >- Attribute a = itr.next(); >- if (a != null && a.getParameterName() != null && a.getParameterName().compareTo("") != 0 && !a.isHidden()) { >+ AbstractRepositoryReportAttribute a = itr.next(); >+ if (a != null && a.getID() != null && a.getID().compareTo("") != 0) { // && >+ // !a.isHidden() > // String key = a.getName(); > String value = null; > >@@ -259,20 +258,20 @@ > // && a.isHidden()) { > // // we have a hidden attribute, add it to the > // // posting >- value = a.getValue(); >+ value = a.getValue(); > if (value == null) > continue; >- form.add(a.getParameterName(), value); >+ form.add(a.getID(), value); > } > } > > // form.add(KEY_BUG_FILE_LOC, ""); > > // specify the product >- form.add(BugReportElement.PRODUCT.getKeyString(), model.getProduct()); >+ form.add(BugzillaReportElement.PRODUCT.getKeyString(), model.getProduct()); > > // add the summary to the bug post >- form.add(BugReportElement.SHORT_DESC.getKeyString(), model.getSummary()); >+ form.add(BugzillaReportElement.SHORT_DESC.getKeyString(), model.getSummary()); > > // BugzillaServerVersion bugzillaServerVersion = > // IBugzillaConstants.BugzillaServerVersion.fromString(repository >@@ -304,7 +303,7 @@ > * > * @param removeCC > */ >- public static BugzillaReportSubmitForm makeExistingBugPost(BugReport bug, TaskRepository repository, >+ public static BugzillaReportSubmitForm makeExistingBugPost(BugzillaReport bug, TaskRepository repository, > Set<String> removeCC) { > > BugzillaReportSubmitForm bugReportPostHandler = new BugzillaReportSubmitForm(); >@@ -317,19 +316,22 @@ > } > > // go through all of the attributes and add them to the bug post >- for (Iterator<Attribute> it = bug.getAttributes().iterator(); it.hasNext();) { >- Attribute a = it.next(); >- if (a != null && a.getParameterName() != null && a.getParameterName().compareTo("") != 0 && !a.isHidden()) { >- String value = a.getNewValue(); >+ for (Iterator<AbstractRepositoryReportAttribute> it = bug.getAttributes().iterator(); it.hasNext();) { >+ AbstractRepositoryReportAttribute a = it.next(); >+ >+ if (a != null && a.getID() != null && a.getID().compareTo("") != 0 && !a.isHidden()) { >+ String value = a.getValue(); > // add the attribute to the bug post >- bugReportPostHandler.add(a.getParameterName(), value != null ? value : ""); >- } else if (a != null && a.getParameterName() != null && a.getParameterName().compareTo("") != 0 >- && a.isHidden()) { >+ bugReportPostHandler.add(a.getID(), value != null ? value : ""); >+ } else if (a != null && a.getID() != null && a.getID().compareTo("") != 0 && a.isHidden()) { > // we have a hidden attribute and we should send it back. >- bugReportPostHandler.add(a.getParameterName(), a.getValue()); >+ bugReportPostHandler.add(a.getID(), a.getValue()); > } > } > >+ // when posting the bug id is encoded in a hidden field named 'id' >+ bugReportPostHandler.add(KEY_ID, bug.getAttributeValue(BugzillaReportElement.BUG_ID)); >+ > // add the operation to the bug post > Operation o = bug.getSelectedOperation(); > if (o == null) >@@ -345,14 +347,15 @@ > } > } > bugReportPostHandler.add(KEY_FORM_NAME, VAL_PROCESS_BUG); >- bug.setNewNewComment(formatTextToLineWrap(bug.getNewNewComment(), repository)); >- if (bug.getAttribute(BugReport.ATTR_SUMMARY) != null) { >- bugReportPostHandler.add(KEY_SHORT_DESC, bug.getAttribute(BugReport.ATTR_SUMMARY).getNewValue()); >+ // bug.setNewNewComment(formatTextToLineWrap(bug.getNewComment(), >+ // repository)); >+ if (bug.getAttribute(BugzillaReportElement.SHORT_DESC) != null) { >+ bugReportPostHandler.add(KEY_SHORT_DESC, bug.getAttribute(BugzillaReportElement.SHORT_DESC).getValue()); > } > > // add the new comment to the bug post if there is some text in it >- if (bug.getNewNewComment().length() != 0) { >- bugReportPostHandler.add(KEY_COMMENT, bug.getNewNewComment()); >+ if (bug.getNewComment().length() != 0) { >+ bugReportPostHandler.add(KEY_COMMENT, bug.getNewComment()); > } > > if (removeCC != null && removeCC.size() > 0) { >@@ -431,6 +434,10 @@ > } > postConnection.setRequestProperty(REQUEST_PROPERTY_CONTENT_TYPE, contentTypeString); > // get the url for the update with all of the changed values >+ >+ // Used to debug posted report >+ // System.err.println(getPostBody()); >+ > byte[] body = getPostBody().getBytes(); > postConnection.setRequestProperty(REQUEST_PROPERTY_CONTENT_LENGTH, String.valueOf(body.length)); > >@@ -455,7 +462,8 @@ > > String aString = in.readLine(); > >- // while(aString != null) { >+ // Used to debug reponse from bugzilla server >+ // while (aString != null) { > // System.err.println(aString); > // aString = in.readLine(); > // } >@@ -631,27 +639,31 @@ > > /** > * Sets the cc field to the user's address if a cc has not been specified to >- * ensure that commenters are on the cc list. >+ * ensure that commenters are on the cc list. TODO: Review this mechanism > * > * @author Wesley Coelho > */ >- private static void setDefaultCCValue(BugReport bug, TaskRepository repository) { >- Attribute newCCattr = bug.getAttributeForKnobName(KEY_NEWCC); >- Attribute owner = bug.getAttribute(KEY_ASSIGNED_TO); >+ private static void setDefaultCCValue(BugzillaReport bug, TaskRepository repository) { >+ // AbstractRepositoryReportAttribute newCCattr = >+ // bug.getAttributeForKnobName(KEY_NEWCC); >+ AbstractRepositoryReportAttribute owner = bug.getAttribute(BugzillaReportElement.ASSIGNED_TO); > > // Don't add the cc if the user is the bug owner > if (repository.getUserName() == null > || (owner != null && owner.getValue().indexOf(repository.getUserName()) != -1)) { >- MylarStatusHandler.log("Could not determine CC value for repository: " + repository, null); >+ // MylarStatusHandler.log("Could not determine CC value for >+ // repository: " + repository, null); > return; > } >- >- // Add the user to the cc list >- if (newCCattr != null) { >- if (newCCattr.getNewValue().equals("")) { >- newCCattr.setNewValue(repository.getUserName()); >- } >+ // Don't add cc if already there >+ AbstractRepositoryReportAttribute ccAttribute = bug.getAttribute(BugzillaReportElement.CC); >+ if (ccAttribute != null && ccAttribute.getValues().contains(repository.getUserName())) { >+ return; > } >+ BugzillaReportAttribute newCCattr = new BugzillaReportAttribute(BugzillaReportElement.NEWCC); >+ // Add the user to the cc list >+ newCCattr.setValue(repository.getUserName()); >+ bug.addAttribute(BugzillaReportElement.NEWCC, newCCattr); > } > > /** >Index: src/org/eclipse/mylar/internal/bugzilla/core/BugzillaTools.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/BugzillaTools.java,v >retrieving revision 1.2 >diff -u -r1.2 BugzillaTools.java >--- src/org/eclipse/mylar/internal/bugzilla/core/BugzillaTools.java 7 Feb 2006 00:54:06 -0000 1.2 >+++ src/org/eclipse/mylar/internal/bugzilla/core/BugzillaTools.java 8 May 2006 23:07:24 -0000 >@@ -10,7 +10,7 @@ > *******************************************************************************/ > package org.eclipse.mylar.internal.bugzilla.core; > >-import org.eclipse.mylar.bugzilla.core.IBugzillaBug; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > > /** > * Miscellaneous constants and functions for this plugin. >@@ -53,7 +53,7 @@ > return name; > } > >- public static String getHandle(IBugzillaBug bug) { >+ public static String getHandle(BugzillaReport bug) { > return getHandle(bug.getRepositoryUrl(), bug.getId()); > } > >@@ -61,7 +61,7 @@ > return server + ";" + id; > } > >- public static String getName(IBugzillaBug bug) { >+ public static String getName(BugzillaReport bug) { > return bug.getRepositoryUrl() + ": Bug#: " + bug.getId() + ": " + bug.getSummary(); > } > >Index: src/org/eclipse/mylar/internal/bugzilla/core/search/BugzillaSearchResultCollector.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/search/BugzillaSearchResultCollector.java,v >retrieving revision 1.2 >diff -u -r1.2 BugzillaSearchResultCollector.java >--- src/org/eclipse/mylar/internal/bugzilla/core/search/BugzillaSearchResultCollector.java 7 Feb 2006 00:54:07 -0000 1.2 >+++ src/org/eclipse/mylar/internal/bugzilla/core/search/BugzillaSearchResultCollector.java 8 May 2006 23:07:24 -0000 >@@ -19,8 +19,9 @@ > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; > import org.eclipse.search.ui.NewSearchUI; > import org.eclipse.search.ui.text.Match; > >@@ -120,15 +121,15 @@ > * Returns a map where BugReport's attributes are entered into a Map using > * the same key/value pairs as those created on a search hit marker. > */ >- public static Map<String, Object> getAttributeMap(BugReport bug) { >+ public static Map<String, Object> getAttributeMap(BugzillaReport bug) { > HashMap<String, Object> map = new HashMap<String, Object>(); > map.put(IBugzillaConstants.HIT_MARKER_ATTR_ID, new Integer(bug.getId())); > map.put(IBugzillaConstants.HIT_MARKER_ATTR_REPOSITORY, bug.getRepositoryUrl()); > map.put(IBugzillaConstants.HIT_MARKER_ATTR_DESC, bug.getDescription()); > map.put(IBugzillaConstants.HIT_MARKER_ATTR_SEVERITY, >- mapValue(bug.getAttribute("Severity").getValue(), severity)); >+ mapValue(bug.getAttribute(BugzillaReportElement.BUG_SEVERITY).getValue(), severity)); > map.put(IBugzillaConstants.HIT_MARKER_ATTR_PRIORITY, >- mapValue(bug.getAttribute("Priority").getValue(), priority)); >+ mapValue(bug.getAttribute(BugzillaReportElement.PRIORITY).getValue(), priority)); > map.put(IBugzillaConstants.HIT_MARKER_ATTR_PLATFORM, bug.getAttribute("Hardware").getValue()); > map.put(IBugzillaConstants.HIT_MARKER_ATTR_STATE, mapValue(bug.getStatus(), state)); > map.put(IBugzillaConstants.HIT_MARKER_ATTR_RESULT, mapValue(bug.getResolution(), result)); >Index: src/org/eclipse/mylar/internal/bugzilla/core/internal/BugzillaReportElement.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/bugzilla/core/internal/BugzillaReportElement.java >diff -N src/org/eclipse/mylar/internal/bugzilla/core/internal/BugzillaReportElement.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/bugzilla/core/internal/BugzillaReportElement.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,106 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.bugzilla.core.internal; >+ >+/** >+ * Bugzilla XML element enum. Each enum has the attribute name >+ * and associated xml element tag name. >+ * >+ * @author Rob Elves >+ */ >+public enum BugzillaReportElement { >+ // Format: ENUM ( "pretty name", "xml key", <hidden: true/false>, <multivalued: true/false>) >+ // Hidden elements are not automatically displayed in ui >+ ASSIGNED_TO ("Assigned to:", "assigned_to"), >+ ATTACHID ("attachid", "attachid"), >+ ATTACHMENT ("attachment", "attachment"), >+ BLOCKED ("Bug blocks:", "blocked"), >+ BUG ("bug","bug", true), >+ BUG_FILE_LOC ("URL:", "bug_file_loc", true), >+ BUG_ID ("Bug:", "bug_id", true), >+ BUG_SEVERITY ("Severity:", "bug_severity", false), >+ BUG_STATUS ("Status:", "bug_status", false, true), >+ BUG_WHEN ("bug_when", "bug_when", true, true), >+ BUGZILLA ("bugzilla", "bugzilla", true), >+ CC ("CC:", "cc", true, true), >+ CCLIST_ACCESSIBLE ("cclist_accessible", "cclist_accessible", true), >+ CLASSIFICATION ("Classification:", "classification", true), >+ CLASSIFICATION_ID ("Classification ID:", "classification_id", true), >+ COMPONENT ("Component:", "component", false), >+ CREATION_TS ("Creation date:", "creation_ts", true), >+ CTYPE ("Content Type", "ctype"), >+ DATA ("data", "data"), >+ DATE ("Date", "date"), >+ DELTA_TS ("Last Modification", "delta_ts", true), >+ DEPENDSON ("Bug depends on:", "dependson"), >+ DESC ("desc", "desc"), >+ EVERCONFIRMED ("everconfirmed", "everconfirmed", true), >+ FILENAME ("filename", "filename"), >+ IS_OBSOLETE ("Obsolete", "isobsolete", true), >+ KEYWORDS ("Keywords:", "keywords", true), >+ LONG_DESC ("Description:", "long_desc"), >+ LONGDESCLENGTH ("Number of comments", "longdesclength", true), >+ NEWCC ("Add CC:", "newcc", true), >+ OP_SYS ("OS:", "op_sys", false), >+ PRIORITY ("Priority:", "priority", false), >+ PRODUCT ("Product:", "product", false), >+ REP_PLATFORM ("Platform:", "rep_platform", false), >+ REPORTER ("Reporter:", "reporter", false, true), >+ REPORTER_ACCESSIBLE ("reporter_accessible", "reporter_accessible", true), >+ RESOLUTION ("Resolution:", "resolution", false, true), // Exiting bug field, new cc >+ SHORT_DESC ("Summary:", "short_desc", true), >+ TARGET_MILESTONE ("Target milestone:", "target_milestone", false), >+ THETEXT ("thetext", "thetext"), >+ TYPE ("type", "type"), >+ UNKNOWN ("UNKNOWN", "UNKNOWN"), >+ VERSION ("Version:", "version", false), >+ VOTES ("Votes:", "votes", false, true), >+ WHO ("who", "who"); >+ >+ >+ >+ private final boolean isHidden; >+ private final boolean isReadOnly; >+ private final String keyString; >+ private final String prettyName; >+ >+ BugzillaReportElement(String prettyName, String fieldName) { >+ this(prettyName, fieldName, false, false); >+ } >+ >+ BugzillaReportElement(String prettyName, String fieldName, boolean hidden) { >+ this(prettyName, fieldName, hidden, false); >+ } >+ >+ BugzillaReportElement(String prettyName, String fieldName, boolean hidden, boolean readonly) { >+ this.prettyName = prettyName; >+ this.keyString = fieldName; >+ this.isHidden = hidden; >+ this.isReadOnly = readonly; >+ } >+ >+ public String getKeyString() { >+ return keyString; >+ } >+ >+ public boolean isHidden() { >+ return isHidden; >+ } >+ >+ public boolean isReadOnly() { >+ return isReadOnly; >+ } >+ >+ public String toString() { >+ return prettyName; >+ } >+} >Index: src/org/eclipse/mylar/internal/bugzilla/core/NewBugzillaReport.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/bugzilla/core/NewBugzillaReport.java >diff -N src/org/eclipse/mylar/internal/bugzilla/core/NewBugzillaReport.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/bugzilla/core/NewBugzillaReport.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,223 @@ >+/******************************************************************************* >+ * Copyright (c) 2003 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.mylar.internal.bugzilla.core; >+ >+import java.io.Serializable; >+import java.util.Date; >+ >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; >+ >+/** >+ * This class is used to store data about the new bug that is being created >+ * while the wizard is being used >+ * >+ * @author Eric Booth >+ * @author Rob Elves >+ */ >+public class NewBugzillaReport extends BugzillaReport implements Serializable { >+ >+ /** Automatically generated serialVersionUID */ >+ private static final long serialVersionUID = 3977859587934335283L; >+ >+ /** Whether the attributes have been parsed yet or not */ >+ protected boolean hasParsedAttributes = false; >+ >+ /** Whether the products have been parsed yet or not */ >+ protected boolean hasParsedProducts = false; >+// >+// // /** The bug's id */ >+// // protected final int id; >+// >+ /** The product that the bug is for */ >+ protected String product; >+// >+// // /** A list of the attributes that can be changed for the new bug */ >+// // public Map<String, AbstractRepositoryReportAttribute> attributes = new >+// // LinkedHashMap<String, AbstractRepositoryReportAttribute>(); >+// >+ /** The summary for the bug */ >+ protected String summary = ""; >+ >+ /** The description for the bug */ >+ protected String description = ""; >+ >+ /** >+ * Flag to indicate status of connection to Bugzilla server to identify >+ * whether ProductConfiguration should be used instead >+ */ >+ protected boolean connected = true; >+ >+ /** Whether or not this bug report is saved offline. */ >+ protected boolean savedOffline = false; >+ >+ /** >+ * Creates a new <code>NewBugModel</code>. The id chosen for this bug is >+ * based on the id of the last <code>NewBugModel</code> that was created. >+ */ >+ public NewBugzillaReport(String repositoryURL) { >+ super(BugzillaPlugin.getDefault().getOfflineReports().getNextOfflineBugId(), repositoryURL); >+ // id = >+ // BugzillaPlugin.getDefault().getOfflineReports().getNextOfflineBugId(); >+ } >+ >+ // public AbstractRepositoryReportAttribute getAttribute(String key) { >+ // return attributes.get(key); >+ // } >+ >+ // /** >+ // * Get the list of attributes for this model >+ // * >+ // * @return An <code>ArrayList</code> of the models attributes >+ // */ >+ // public List<AbstractRepositoryReportAttribute> getAttributes() { >+ // // create an array list to store the attributes in >+ // ArrayList<AbstractRepositoryReportAttribute> attributeEntries = new >+ // ArrayList<AbstractRepositoryReportAttribute>(attributes.keySet().size()); >+ // >+ // // go through each of the attribute keys >+ // for (Iterator<String> it = attributes.keySet().iterator(); it.hasNext();) >+ // { >+ // // get the key for the attribute >+ // String key = it.next(); >+ // >+ // // get the attribute and add it to the list >+ // AbstractRepositoryReportAttribute attribute = attributes.get(key); >+ // attributeEntries.add(attribute); >+ // } >+ // >+ // // return the list of attributes for the bug >+ // return attributeEntries; >+ // } >+ >+ // public int getId() { >+ // return id; >+ // } >+ // >+ // public String getRepositoryUrl() { >+ // return BugzillaTools.OFFLINE_SERVER_DEFAULT; >+ // } >+ >+ public String getLabel() { >+ return "New Bug #" + getId(); >+ } >+ >+ public String getDescription() { >+ return description; >+ } >+ >+ public void setDescription(String newDescription) { >+ description = newDescription; >+ } >+ >+ public String getSummary() { >+ return summary; >+ } >+ >+ public void setSummary(String newSummary) { >+ summary = newSummary; >+ } >+ >+ /** >+ * @return The product that the bug is for. >+ */ >+ public String getProduct() { >+ return product; >+ } >+ >+ /** >+ * Sets the product that the bug is for. >+ * >+ * @param product >+ * The product. >+ */ >+ public void setProduct(String product) { >+ this.product = product; >+ } >+ >+ /** >+ * @return Flag to indicate status of connection to Bugzilla server (to >+ * identify whether ProductConfiguration should be used instead) >+ */ >+ public boolean isConnected() { >+ return connected; >+ } >+ >+ /** >+ * Sets the value of the flag to indicate status of connection to Bugzilla >+ * server (to identify whether ProductConfiguration should be used instead) >+ * >+ * @param newConnectionStatus >+ * <code>true</code> if the bug is connected. >+ */ >+ public void setConnected(boolean newConnectionStatus) { >+ connected = newConnectionStatus; >+ } >+ >+ /** >+ * @return Returns whether the attributes have been parsed yet or not. >+ */ >+ public boolean hasParsedAttributes() { >+ return hasParsedAttributes; >+ } >+ >+ /** >+ * Sets whether the attributes have been parsed yet or not. >+ * >+ * @param hasParsedAttributes >+ * <code>true</code> if the attributes have been parsed. >+ */ >+ public void setParsedAttributesStatus(boolean hasParsedAttributes) { >+ this.hasParsedAttributes = hasParsedAttributes; >+ } >+ >+ /** >+ * @return Returns whether the products have been parsed yet or not. >+ */ >+ public boolean hasParsedProducts() { >+ return hasParsedProducts; >+ } >+ >+ /** >+ * Sets whether the products have been parsed yet or not. >+ * >+ * @param hasParsedProducts >+ * <code>true</code> if the products have been parsed. >+ */ >+ public void setParsedProductsStatus(boolean hasParsedProducts) { >+ this.hasParsedProducts = hasParsedProducts; >+ } >+ >+ public boolean isSavedOffline() { >+ return savedOffline; >+ } >+ >+ public boolean isLocallyCreated() { >+ return true; >+ } >+ >+ public void setOfflineState(boolean newOfflineState) { >+ savedOffline = newOfflineState; >+ } >+ >+ public boolean hasChanges() { >+ return true; >+ } >+ >+ /** returns null */ >+ public Date getCreated() { >+ return null; >+ } >+ >+ public Date getLastModified() { >+ return null; >+ } >+ >+} >Index: src/org/eclipse/mylar/bugzilla/core/BugzillaAttributeFactory.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/core/BugzillaAttributeFactory.java >diff -N src/org/eclipse/mylar/bugzilla/core/BugzillaAttributeFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/bugzilla/core/BugzillaAttributeFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.core; >+ >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; >+ >+/** >+ * @author Rob Elves >+ */ >+public class BugzillaAttributeFactory extends AbstractAttributeFactory { >+ >+ @Override >+ public AbstractRepositoryReportAttribute createAttribute(Object key) { >+ return new BugzillaReportAttribute((BugzillaReportElement) key); >+ } >+ >+} >Index: src/org/eclipse/mylar/bugzilla/core/AbstractAttributeFactory.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/core/AbstractAttributeFactory.java >diff -N src/org/eclipse/mylar/bugzilla/core/AbstractAttributeFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/bugzilla/core/AbstractAttributeFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.core; >+ >+/** >+ * @author Rob Elves >+ */ >+public abstract class AbstractAttributeFactory { >+ >+ public abstract AbstractRepositoryReportAttribute createAttribute(Object key); >+ >+} >Index: src/org/eclipse/mylar/bugzilla/core/ReportAttachment.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/core/ReportAttachment.java >diff -N src/org/eclipse/mylar/bugzilla/core/ReportAttachment.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/bugzilla/core/ReportAttachment.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,85 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.core; >+ >+import java.io.Serializable; >+import java.text.SimpleDateFormat; >+import java.util.Date; >+ >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; >+ >+/** >+ * TODO: Make generic. This currently represents Bugzilla attachments only >+ * @author relves >+ */ >+public class ReportAttachment extends AttributeContainer implements Serializable { >+ >+ private static final long serialVersionUID = -9123545810321250785L; >+ >+ /** Parser for dates in the report */ >+ private static SimpleDateFormat creation_ts_date_format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); >+ >+ private boolean isObsolete = false; >+ >+ private Date created; >+ >+ public boolean isObsolete() { >+ return isObsolete; >+ } >+ >+ public void setObsolete(boolean isObsolete) { >+ this.isObsolete = isObsolete; >+ } >+ >+ >+ /** >+ * may return null if date is unknown/unparseable >+ */ >+ public Date getDateCreated() { >+ if(created == null) { >+ //created = Calendar.getInstance().getTime(); >+ try { >+ created = creation_ts_date_format.parse(getAttributeValue(BugzillaReportElement.DATE)); >+ } catch (Exception e) { >+ } >+ } >+ return created; >+ } >+ >+ /** >+ * Currently returns empty string. XML from bugzilla >+ * doesn't include who attached directly in attachment data >+ * TODO: Retrieve from associated comment >+ * @return >+ */ >+ public String getAuthor() { >+ return ""; >+ } >+ >+ public String getDescription() { >+ //System.err.println(getAttributeValue(BugzillaReportElement.DESC)); >+ return getAttributeValue(BugzillaReportElement.DESC); >+ } >+ >+ public int getId() { >+ try { >+ return Integer.parseInt(getAttributeValue(BugzillaReportElement.ATTACHID)); >+ } catch (NumberFormatException e) { >+ return -1; >+ } >+ } >+ >+ public Object getContentType() { >+ return getAttributeValue(BugzillaReportElement.CTYPE); >+ } >+ >+} >Index: src/org/eclipse/mylar/bugzilla/core/AbstractRepositoryReport.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/core/AbstractRepositoryReport.java >diff -N src/org/eclipse/mylar/bugzilla/core/AbstractRepositoryReport.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/bugzilla/core/AbstractRepositoryReport.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,179 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.core; >+ >+import java.io.Serializable; >+import java.io.UnsupportedEncodingException; >+import java.nio.charset.Charset; >+import java.util.ArrayList; >+import java.util.List; >+ >+/** >+ * @author Mik Kersten >+ * @author Rob Elves >+ */ >+public abstract class AbstractRepositoryReport extends AttributeContainer implements Serializable { >+ >+ private String charset = null; >+ >+ private int reportID; >+ >+ private String repositoryURL; >+ >+ private List<Comment> comments = new ArrayList<Comment>(); >+ >+ private List<ReportAttachment> attachments = new ArrayList<ReportAttachment>(); >+ >+ private boolean hasChanges = false; >+ >+ public AbstractRepositoryReport(int id, String repositoryURL) { >+ super(); >+ this.reportID = id; >+ this.repositoryURL = repositoryURL; >+ } >+ >+ public void addComment(Comment comment) { >+ Comment preceding = null; >+ if (comments.size() > 0) { >+ // if there are some comments, get the last comment and set the next >+ // value to be the new comment >+ preceding = comments.get(comments.size() - 1); >+ preceding.setNext(comment); >+ } >+ // set the comments previous value to the preceeding one >+ comment.setPrevious(preceding); >+ >+ // comment.setText(decodeStringFromCharset(comment.getText())); >+ // add the comment to the comment list >+ comments.add(comment); >+ } >+ >+ public List<Comment> getComments() { >+ return comments; >+ } >+ >+ public void addAttachment(ReportAttachment attachment) { >+ attachments.add(attachment); >+ } >+ >+ public List<ReportAttachment> getAttachments() { >+ return attachments; >+ } >+ >+ public int getId() { >+ return reportID; >+ } >+ >+ /** >+ * @return the server for this report >+ */ >+ public String getRepositoryUrl() { >+ return repositoryURL; >+ } >+ >+ public String getCharset() { >+ return charset; >+ } >+ >+ public void setCharset(String charset) { >+ this.charset = charset; >+ } >+ >+ public boolean hasChanges() { >+ return hasChanges ; >+ } >+ >+ public void setHasChanged(boolean b) { >+ hasChanges = b; >+ } >+ >+ /** >+ * @return <code>true</code> if this report was created locally, and does not >+ * yet exist on a server. >+ */ >+ public abstract boolean isLocallyCreated(); >+ >+ /** >+ * @return <code>true</code> if this report is saved offline. >+ */ >+ public abstract boolean isSavedOffline(); >+ >+ /** >+ * Sets whether or not this report is saved offline. >+ * >+ * @param newOfflineState >+ * <code>true</code> if this bug is saved offline >+ */ >+ public abstract void setOfflineState(boolean newOfflineState); >+ >+// public String getAttributeValue(Object key) { >+// AbstractRepositoryReportAttribute attribute = getAttribute(key); >+// if(attribute != null) { >+// return attribute.getValue(); >+// } >+// return ""; >+// } >+ >+ public List<String> getAttributeValues(Object key) { >+ AbstractRepositoryReportAttribute attribute = getAttribute(key); >+ if(attribute != null) { >+ return attribute.getValues(); >+ } >+ return new ArrayList<String>(); >+ } >+ >+ /** >+ * sets a value on an attribute, if attribute doesn't exist, >+ * appropriate attribute is created >+ */ >+ public void setAttributeValue(Object key, String value) { >+ AbstractRepositoryReportAttribute attrib = getAttribute(key); >+ if(attrib == null) { >+ attrib = getAttributeFactory().createAttribute(key); >+ this.addAttribute(key, attrib); >+ } >+ attrib.setValue(value); >+ } >+ >+ public void addAttributeValue(Object key, String value) { >+ AbstractRepositoryReportAttribute attrib = getAttribute(key); >+ if (attrib != null) { >+ attrib.addValue(value); >+ } else { >+ attrib = getAttributeFactory().createAttribute(key); >+ attrib.addValue(value); >+ this.addAttribute(key, attrib); >+ } >+ } >+ >+ public void removeAttributeValue(Object key, String value) { >+ AbstractRepositoryReportAttribute attrib = getAttribute(key); >+ if (attrib != null) { >+ attrib.removeValue(value); >+ } >+ } >+ >+ public abstract AbstractAttributeFactory getAttributeFactory(); >+ >+ protected String decodeStringFromCharset(String string) { >+ String decoded = string; >+ if (charset != null && string != null && Charset.availableCharsets().containsKey(charset)) { >+ try { >+ decoded = new String(string.getBytes(), charset); >+ } catch (UnsupportedEncodingException e) { >+ // ignore >+ } >+ } >+ return decoded; >+ } >+ >+} >Index: src/org/eclipse/mylar/bugzilla/core/BugzillaReportAttribute.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/core/BugzillaReportAttribute.java >diff -N src/org/eclipse/mylar/bugzilla/core/BugzillaReportAttribute.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/bugzilla/core/BugzillaReportAttribute.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.core; >+ >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; >+ >+public class BugzillaReportAttribute extends AbstractRepositoryReportAttribute { >+ >+ private static final long serialVersionUID = 6959987055086133307L; >+ >+ public BugzillaReportAttribute(BugzillaReportElement element) { >+ super(element.toString(), element.isHidden()); >+ super.setID(element.getKeyString()); >+ super.setReadOnly(element.isReadOnly()); >+ } >+ >+} >Index: src/org/eclipse/mylar/internal/bugzilla/core/internal/RepositoryConfigurationFactory.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/bugzilla/core/internal/RepositoryConfigurationFactory.java >diff -N src/org/eclipse/mylar/internal/bugzilla/core/internal/RepositoryConfigurationFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/bugzilla/core/internal/RepositoryConfigurationFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,117 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.bugzilla.core.internal; >+ >+import java.io.BufferedReader; >+import java.io.IOException; >+import java.io.InputStreamReader; >+import java.io.StringReader; >+import java.net.URL; >+import java.net.URLConnection; >+ >+import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; >+import org.eclipse.mylar.internal.core.util.MylarStatusHandler; >+import org.eclipse.mylar.provisional.tasklist.TaskRepository; >+import org.xml.sax.ErrorHandler; >+import org.xml.sax.InputSource; >+import org.xml.sax.SAXException; >+import org.xml.sax.SAXParseException; >+import org.xml.sax.XMLReader; >+import org.xml.sax.helpers.XMLReaderFactory; >+ >+/** >+ * Reads bugzilla product configuration from config.cgi on server in RDF format. >+ * >+ * @author Rob Elves >+ */ >+public class RepositoryConfigurationFactory { >+ >+ private static final String CONFIG_RDF_URL = "/config.cgi?ctype=rdf"; >+ >+ private static RepositoryConfigurationFactory instance; >+ >+ private RepositoryConfigurationFactory() { >+ // no initial setup needed >+ } >+ >+ public static RepositoryConfigurationFactory getInstance() { >+ if (instance == null) { >+ instance = new RepositoryConfigurationFactory(); >+ } >+ return instance; >+ } >+ >+ public RepositoryConfiguration getConfiguration(TaskRepository repository) throws IOException { >+ String configUrlStr = repository.getUrl() + CONFIG_RDF_URL; >+ configUrlStr = BugzillaRepositoryUtil.addCredentials(repository, configUrlStr); >+ URLConnection c = new URL(configUrlStr).openConnection(); >+ BufferedReader in = new BufferedReader(new InputStreamReader(c.getInputStream())); >+ >+ SaxConfigurationContentHandler contentHandler = new SaxConfigurationContentHandler(); >+ >+ try { >+ StringBuffer result = XmlCleaner.clean(in); >+ StringReader strReader = new StringReader(result.toString()); >+ XMLReader reader = XMLReaderFactory.createXMLReader(); >+ reader.setErrorHandler(new SaxErrorHandler()); >+ reader.setContentHandler(contentHandler); >+ reader.parse(new InputSource(strReader)); >+ } catch (SAXException e) { >+ throw new IOException("Unable to read server configuration."); >+ } >+ return contentHandler.getConfiguration(); >+ >+ } >+ >+ // public RepositoryConfiguration getConfiguration(String server) throws >+ // IOException { >+ // URL serverURL = new URL(server + CONFIG_RDF_URL); >+ // BugzillaRepositoryUtil.addCredentials(repository, serverURL) >+ // URLConnection c = serverURL.openConnection(); >+ // BufferedReader in = new BufferedReader(new >+ // InputStreamReader(c.getInputStream())); >+ // >+ // SaxConfigurationContentHandler contentHandler = new >+ // SaxConfigurationContentHandler(); >+ // >+ // try { >+ // StringBuffer result = XmlCleaner.clean(in); >+ // StringReader strReader = new StringReader(result.toString()); >+ // XMLReader reader = XMLReaderFactory.createXMLReader(); >+ // reader.setErrorHandler(new SaxErrorHandler()); >+ // reader.setContentHandler(contentHandler); >+ // reader.parse(new InputSource(strReader)); >+ // } catch (SAXException e) { >+ // throw new IOException("Unable to read server configuration."); >+ // } >+ // return contentHandler.getConfiguration(); >+ // >+ // } >+ >+ class SaxErrorHandler implements ErrorHandler { >+ >+ public void error(SAXParseException exception) throws SAXException { >+ MylarStatusHandler.fail(exception, "ServerConfigurationFactory: " + exception.getLocalizedMessage(), false); >+ } >+ >+ public void fatalError(SAXParseException exception) throws SAXException { >+ MylarStatusHandler.fail(exception, "ServerConfigurationFactory: " + exception.getLocalizedMessage(), false); >+ >+ } >+ >+ public void warning(SAXParseException exception) throws SAXException { >+ // ignore >+ } >+ >+ } >+ >+} >Index: src/org/eclipse/mylar/bugzilla/core/AbstractRepositoryReportAttribute.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/core/AbstractRepositoryReportAttribute.java >diff -N src/org/eclipse/mylar/bugzilla/core/AbstractRepositoryReportAttribute.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/bugzilla/core/AbstractRepositoryReportAttribute.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,202 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.core; >+ >+import java.io.Serializable; >+import java.util.ArrayList; >+import java.util.LinkedHashMap; >+import java.util.List; >+import java.util.Map; >+ >+/** >+ * Class representing a report attribute may contain child attributes >+ * >+ * @author Rob Elves >+ */ >+public abstract class AbstractRepositoryReportAttribute implements Serializable { >+ >+ private boolean hidden = false; >+ private boolean isReadOnly = false;; >+ >+ /** Attribute pretty printing name */ >+ private String name; >+ >+ /** Name of the option used when updating the attribute on the server */ >+ private String id; >+ >+ /** Legal values of the attribute */ >+ private LinkedHashMap<String, String> optionValues; >+ >+ /** >+ * Attribute's values (selected or added) >+ */ >+ private List<String> values = new ArrayList<String>(); >+ >+ public AbstractRepositoryReportAttribute(String name, boolean hidden) { >+ // initialize the name and its legal values >+ this.name = name; >+ this.hidden = hidden; >+ optionValues = new LinkedHashMap<String, String>(); >+ } >+ >+ public String getName() { >+ return name; >+ } >+ >+ public String getID() { >+ return id; >+ } >+ >+ public boolean isReadOnly() { >+ return isReadOnly ;//optionValues.size() > 0; >+ } >+ >+ public void setReadOnly(boolean readonly) { >+ this.isReadOnly = readonly; >+ } >+ >+ public Map<String, String> getOptionValues() { >+ return optionValues; >+ } >+ >+ public String getValue() { >+ if (values.size() > 0) { >+ return values.get(0); >+ } else { >+ return ""; >+ } >+ } >+ >+ public List<String> getValues() { >+ return values; >+ } >+ >+ public void setValue(String value) { >+ if(values.size() > 0) { >+ values.set(0, value); >+ } else { >+ values.add(value); >+ } >+ // newValues.add(value); >+ } >+ >+ public void setValues(List<String> values) { >+ values.clear(); >+ values.addAll(values); >+ } >+ >+ public void addValue(String value) { >+ values.add(value); >+ } >+ >+ public void removeValue(String value) { >+ if (values.contains(value)) { >+ values.remove(values.indexOf(value)); >+ } >+ } >+ >+ public void clearValues() { >+ values.clear(); >+ } >+ >+ >+ >+ // /** >+ // * Set the new value of the attribute >+ // * >+ // * @param newVal >+ // * The new value of the attribute >+ // */ >+ // public void setNewValue(String newVal) { >+ // newValues.add(newVal); >+ // } >+ // >+ // public void setNewValues(List<String> newVals) { >+ // newValues.clear(); >+ // newValues.addAll(newVals); >+ // } >+ >+ // /** >+ // * Get the new value for the attribute >+ // * >+ // * @return The new value >+ // */ >+ // public String getNewValue() { >+ // if(newValues.size() > 0) { >+ // return values.get(0); >+ // } else { >+ // return ""; >+ // } >+ // } >+ >+ // public List<String> getNewValues() { >+ // return newValues; >+ // } >+ >+ // public boolean isMultiValued() { >+ // return newValues.size() > 1; >+ // } >+ >+ /** >+ * Sets the name of the option used when updating the attribute on the >+ * server >+ * >+ * @param parameterName >+ * The name of the option when updating from the server >+ */ >+ public void setID(String parameterName) { >+ this.id = parameterName; >+ } >+ >+ /** >+ * Adds an attribute option value >+ * >+ * @param readableValue >+ * The value displayed on the screen >+ * @param parameterValue >+ * The option value used when sending the form to the server >+ */ >+ public void addOptionValue(String readableValue, String parameterValue) { >+ optionValues.put(readableValue, parameterValue); >+ } >+ >+ /** >+ * Determine if the field was hidden or not >+ * >+ * @return True if the field was hidden >+ */ >+ public boolean isHidden() { >+ return hidden; >+ } >+ >+ /** >+ * Set whether the field was hidden in the bug >+ * >+ * @param b >+ * Whether the field was hidden or not >+ */ >+ public void setHidden(boolean b) { >+ hidden = b; >+ } >+ >+ public String toString() { >+ return getValue(); >+ } >+ >+ public boolean hasOptions() { >+ return optionValues.size() > 0; >+ } >+ >+ public void clearOptions() { >+ optionValues.clear(); >+ } >+} >Index: src/org/eclipse/mylar/internal/bugzilla/core/internal/SaxBugReportContentHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/bugzilla/core/internal/SaxBugReportContentHandler.java >diff -N src/org/eclipse/mylar/internal/bugzilla/core/internal/SaxBugReportContentHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/bugzilla/core/internal/SaxBugReportContentHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,206 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.bugzilla.core.internal; >+ >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReportAttribute; >+import org.eclipse.mylar.bugzilla.core.Comment; >+import org.eclipse.mylar.bugzilla.core.ReportAttachment; >+import org.eclipse.mylar.internal.core.util.MylarStatusHandler; >+import org.xml.sax.Attributes; >+import org.xml.sax.SAXException; >+import org.xml.sax.helpers.DefaultHandler; >+ >+/** >+ * Parser for xml bugzilla reports. >+ * >+ * @author Rob Elves >+ */ >+public class SaxBugReportContentHandler extends DefaultHandler { >+ >+ private StringBuffer characters; >+ >+ private Comment comment; >+ >+ private int commentNum = 0; >+ >+ private ReportAttachment attachment; >+ >+ private BugzillaReport report; >+ >+ private String errorMessage = null; >+ >+ public SaxBugReportContentHandler(BugzillaReport rpt) { >+ this.report = rpt; >+ } >+ >+ public boolean errorOccurred() { >+ return errorMessage != null; >+ } >+ >+ public String getErrorMessage() { >+ return errorMessage; >+ } >+ >+ public BugzillaReport getReport() { >+ return report; >+ } >+ >+ @Override >+ public void characters(char[] ch, int start, int length) throws SAXException { >+ characters.append(ch, start, length); >+ } >+ >+ @Override >+ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { >+ characters = new StringBuffer(); >+ BugzillaReportElement tag = BugzillaReportElement.UNKNOWN; >+ try { >+ tag = BugzillaReportElement.valueOf(localName.trim().toUpperCase()); >+ } catch (RuntimeException e) { >+ if (e instanceof IllegalArgumentException) { >+ MylarStatusHandler.fail(new Exception(e), "Mylar: Bugzilla report element not known: " >+ + e.getMessage().trim(), false); >+ errorMessage = "Mylar: Bugzilla report element not known: " + e.getMessage().trim(); >+ } >+ } >+ switch (tag) { >+ case BUGZILLA: >+ // Note: here we can get the bugzilla version if necessary >+ break; >+ case BUG: >+ if (attributes != null && (attributes.getValue("error") != null)) { >+ errorMessage = attributes.getValue("error"); >+ } >+ break; >+ case LONG_DESC: >+ comment = new Comment(report, commentNum++); >+ break; >+ case ATTACHMENT: >+ attachment = new ReportAttachment(); >+ if (attributes != null && (attributes.getValue(BugzillaReportElement.IS_OBSOLETE.getKeyString()) != null)) { >+ attachment.addAttribute(BugzillaReportElement.IS_OBSOLETE, new BugzillaReportAttribute( >+ BugzillaReportElement.IS_OBSOLETE)); >+ } >+ break; >+ } >+ >+ } >+ >+ @Override >+ public void endElement(String uri, String localName, String qName) throws SAXException { >+ BugzillaReportElement tag = BugzillaReportElement.valueOf(localName.trim().toUpperCase()); >+ >+ switch (tag) { >+ case BUG_ID: { >+ try { >+ if (report.getId() != Integer.parseInt(characters.toString())) { >+ errorMessage = "Requested report number does not match returned report number."; >+ } >+ } catch (NumberFormatException e) { >+ errorMessage = "Bug id from server did not match requested id."; >+ } >+ >+ AbstractRepositoryReportAttribute attr = report.getAttribute(tag); >+ if (attr == null) { >+ attr = new BugzillaReportAttribute(tag); >+ report.addAttribute(tag, attr); >+ } >+ attr.setValue(characters.toString()); >+ break; >+ } >+ >+ // Comment attributes >+ case WHO: >+ case BUG_WHEN: >+ case THETEXT: >+ if (comment != null) { >+ BugzillaReportAttribute attr = new BugzillaReportAttribute(tag); >+ attr.setValue(characters.toString()); >+ // System.err.println(">>> "+comment.getNumber()+" >+ // "+characters.toString()); >+ comment.addAttribute(tag, attr); >+ } >+ break; >+ case LONG_DESC: >+ if (comment != null) { >+ report.addComment(comment); >+ } >+ break; >+ >+ // Attachment attributes >+ case ATTACHID: >+ case DATE: >+ case DESC: >+ case FILENAME: >+ case CTYPE: >+ case TYPE: >+ if (attachment != null) { >+ BugzillaReportAttribute attr = new BugzillaReportAttribute(tag); >+ attr.setValue(characters.toString()); >+ attachment.addAttribute(tag, attr); >+ } >+ break; >+ case DATA: >+ // TODO: Need to figure out under what circumstanceswhen attachments >+ // are inline and >+ // what to do with them. >+ break; >+ case ATTACHMENT: >+ if (attachment != null) { >+ report.addAttachment(attachment); >+ } >+ break; >+ >+ // IGNORED ELEMENTS >+ case REPORTER_ACCESSIBLE: >+ case CLASSIFICATION_ID: >+ case CLASSIFICATION: >+ case CCLIST_ACCESSIBLE: >+ case EVERCONFIRMED: >+ case BUGZILLA: >+ break; >+ case BUG: >+ // Reached end of bug. Need to set LONGDESCLENGTH to number of >+ // comments >+ AbstractRepositoryReportAttribute numCommentsAttribute = report >+ .getAttribute(BugzillaReportElement.LONGDESCLENGTH); >+ if (numCommentsAttribute == null) { >+ numCommentsAttribute = new BugzillaReportAttribute(BugzillaReportElement.LONGDESCLENGTH); >+ numCommentsAttribute.setValue("" + report.getComments().size()); >+ report.addAttribute(BugzillaReportElement.LONGDESCLENGTH, numCommentsAttribute); >+ } else { >+ numCommentsAttribute.setValue("" + report.getComments().size()); >+ } >+ break; >+ >+ // All others added as report attribute >+ default: >+ AbstractRepositoryReportAttribute attribute = report.getAttribute(tag); >+ if (attribute == null) { >+ // System.err.println(">>> Undeclared attribute added: " + >+ // tag.toString()+" value: "+characters.toString()); >+ attribute = new BugzillaReportAttribute(tag); >+ attribute.setValue(characters.toString()); >+ report.addAttribute(tag, attribute); >+ } else { >+ // System.err.println("Attr: " + attribute.getName() + " = " + >+ // characters.toString()); >+ attribute.addValue(characters.toString()); >+ } >+ break; >+ } >+ >+ } >+ >+} >Index: src/org/eclipse/mylar/bugzilla/core/BugzillaReport.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/core/BugzillaReport.java >diff -N src/org/eclipse/mylar/bugzilla/core/BugzillaReport.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/bugzilla/core/BugzillaReport.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,517 @@ >+/******************************************************************************* >+ * Copyright (c) 2003 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.mylar.bugzilla.core; >+ >+import java.io.Serializable; >+import java.text.SimpleDateFormat; >+import java.util.ArrayList; >+import java.util.Date; >+import java.util.Iterator; >+import java.util.List; >+import java.util.StringTokenizer; >+ >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; >+import org.eclipse.mylar.internal.core.util.MylarStatusHandler; >+ >+/** >+ * A bug report entered in Bugzilla. >+ * >+ * @author Mik Kersten >+ * @author Rob Elves >+ */ >+public class BugzillaReport extends AbstractRepositoryReport implements IBugzillaBug, Serializable { >+ >+ private static final long serialVersionUID = 310066248657960823L; >+ >+ public static final String VAL_STATUS_VERIFIED = "VERIFIED"; >+ >+ public static final String VAL_STATUS_CLOSED = "CLOSED"; >+ >+ public static final String VAL_STATUS_RESOLVED = "RESOLVED"; >+ >+ public static final String VAL_STATUS_NEW = "NEW"; >+ >+ /** Parser for dates in the report */ >+ private static SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); >+ >+ /** Description of the bug */ >+ protected String description; >+ >+ /** Creation timestamp */ >+ protected Date created; >+ >+ /** Modification timestamp */ >+ protected Date lastModified = null; >+ >+ /** The bugs valid keywords */ >+ protected List<String> validKeywords; >+ >+ /** The operations that can be done on the report */ >+ protected List<Operation> operations = new ArrayList<Operation>(); >+ >+ private static final AbstractAttributeFactory attributeFactory = new BugzillaAttributeFactory(); >+ >+ // /** Bug attributes (status, resolution, etc.) */ >+ // protected HashMap<String, AbstractRepositoryReportAttribute> attributes = >+ // new HashMap<String, AbstractRepositoryReportAttribute>(); >+ // >+ // >+ // /** The keys for the bug attributes */ >+ // protected ArrayList<String> attributeKeys = new ArrayList<String>(); >+ >+ // /** A list of comments */ >+ // protected ArrayList<Comment> comments = new ArrayList<Comment>(); >+ >+ /** The value for the new comment to add (text that is saved) */ >+ protected String newComment = ""; >+ >+ // /** The new value for the new comment to add (text from submit editor) */ >+ // protected String newNewComment = ""; >+ >+ /** The operation that was selected to do to the bug */ >+ protected Operation selectedOperation = null; >+ >+ /** Whether or not this bug report is saved offline. */ >+ protected boolean savedOffline = false; >+ >+ protected boolean hasChanges = false; >+ >+ protected String charset = null; >+ >+ // /** >+ // * Get the bugs id >+ // * >+ // * @return The bugs id >+ // */ >+ // public int getId() { >+ // return id; >+ // } >+ // >+ // public String getRepositoryUrl() { >+ // return repositoryUrl; >+ // } >+ >+ public BugzillaReport(int id, String repositoryURL) { >+ super(id, repositoryURL); >+ >+ } >+ >+ /** >+ * TODO: move? >+ */ >+ public static boolean isResolvedStatus(String status) { >+ if (status != null) { >+ return status.equals(VAL_STATUS_RESOLVED) || status.equals(VAL_STATUS_CLOSED) >+ || status.equals(VAL_STATUS_VERIFIED); >+ } else { >+ return false; >+ } >+ } >+ >+ public void addCC(String email) { >+ addAttributeValue(BugzillaReportElement.CC, email); >+ } >+ >+ /** >+ * Add an operation to the bug >+ * >+ * @param o >+ * The operation to add >+ */ >+ public void addOperation(Operation o) { >+ operations.add(o); >+ } >+ >+ /** >+ * Get the person to whom this bug is assigned >+ * >+ * @return The person who is assigned to this bug >+ */ >+ public String getAssignedTo() { >+ return getAttributeValue(BugzillaReportElement.ASSIGNED_TO); >+ } >+ >+ // public AbstractRepositoryReportAttribute >+ // getAttributeForKnobName(BugzillaReportElement element) { >+ // return super.getAttribute(element.getKeyString()); >+ // } >+ >+ // private String decodeStringFromCharset(String string) { >+ // String decoded = string; >+ // if (charset != null && string != null && >+ // Charset.availableCharsets().containsKey(charset)) { >+ // try { >+ // decoded = new String(string.getBytes(), charset); >+ // } catch (UnsupportedEncodingException e) { >+ // // ignore >+ // } >+ // } >+ // return decoded; >+ // } >+ >+ /** >+ * Get the set of addresses in the CC list >+ * >+ * @return A <code>Set</code> of addresses in the CC list >+ */ >+ public List<String> getCC() { >+ return getAttributeValues(BugzillaReportElement.CC); >+ } >+ >+ /** >+ * Get the date that the bug was created >+ * >+ * @return The bugs creation date >+ */ >+ public Date getCreated() { >+ if (created == null) { >+ String dateString = getAttributeValue(BugzillaReportElement.CREATION_TS); >+ try { >+ created = df.parse(dateString); >+ } catch (Exception e) { >+ MylarStatusHandler.fail(e, "Mylar: Unable to parse report #" + getId() + "'s creation date.", false); >+ } >+ } >+ return created; >+ } >+ >+ /** >+ * Get the bugs description >+ * >+ * @return The description of the bug >+ */ >+ public String getDescription() { >+ List<Comment> coms = this.getComments(); >+ if (coms != null && coms.size() > 0) { >+ return coms.get(0).getText(); >+ } else { >+ return ""; >+ } >+ >+ } >+ >+ // public AbstractRepositoryReportAttribute getAttribute(String key) { >+ // return attributes.get(key); >+ // } >+ // >+ // /** >+ // * Get the list of attributes for this bug >+ // * >+ // * @return An <code>ArrayList</code> of the bugs attributes >+ // */ >+ // public List<AbstractRepositoryReportAttribute> getAttributes() { >+ // // create an array list to store the attributes in >+ // ArrayList<AbstractRepositoryReportAttribute> attributeEntries = new >+ // ArrayList<AbstractRepositoryReportAttribute>(attributeKeys.size()); >+ // >+ // // go through each of the attribute keys >+ // for (Iterator<String> it = attributeKeys.iterator(); it.hasNext();) { >+ // // get the key for the attribute >+ // String key = it.next(); >+ // >+ // // get the attribute and add it to the list >+ // AbstractRepositoryReportAttribute attribute = attributes.get(key); >+ // attributeEntries.add(attribute); >+ // } >+ // >+ // // return the list of attributes for the bug >+ // return attributeEntries; >+ // } >+ >+ // public AbstractRepositoryReportAttribute getAttributeForKnobName(String >+ // knobName) { >+ // for (Iterator<String> it = attributeKeys.iterator(); it.hasNext();) { >+ // String key = it.next(); >+ // >+ // AbstractRepositoryReportAttribute attribute = attributes.get(key); >+ // if (attribute != null && attribute.getID() != null >+ // && attribute.getID().compareTo(knobName) == 0) { >+ // return attribute; >+ // } >+ // } >+ // >+ // return null; >+ // } >+ >+ // /** >+ // * @param attribute >+ // * The attribute to add to the bug >+ // */ >+ // public void addAttribute(AbstractRepositoryReportAttribute attribute) { >+ // if (!attributes.containsKey(attribute.getName())) { >+ // attributeKeys.add(attribute.getName()); >+ // } >+ // >+ // attribute.setValue(decodeStringFromCharset(attribute.getValue())); >+ // >+ // // put the value of the attribute into the map, using its name as the >+ // // key >+ // attributes.put(attribute.getName(), attribute); >+ // } >+ >+ // /** >+ // * Get the comments posted on the bug >+ // * >+ // * @return A list of comments for the bug >+ // */ >+ // public ArrayList<Comment> getComments() { >+ // return comments; >+ // } >+ >+ // /** >+ // * Add a comment to the bug >+ // * >+ // * @param comment >+ // * The comment to add to the bug >+ // */ >+ // public void addComment(Comment comment) { >+ // Comment preceding = null; >+ // if (comments.size() > 0) { >+ // // if there are some comments, get the last comment and set the next >+ // // value to be the new comment >+ // preceding = comments.get(comments.size() - 1); >+ // preceding.setNext(comment); >+ // } >+ // // set the comments previous value to the preceeding one >+ // comment.setPrevious(preceding); >+ // >+ // comment.setText(decodeStringFromCharset(comment.getText())); >+ // // add the comment to the comment list >+ // comments.add(comment); >+ // } >+ >+ /** >+ * Get the keywords for the bug >+ * >+ * @return The keywords for the bug >+ */ >+ public List<String> getKeywords() { >+ >+ // get the selected keywords for the bug >+ StringTokenizer st = new StringTokenizer(getAttributeValue(BugzillaReportElement.KEYWORDS), ",", false); >+ List<String> keywords = new ArrayList<String>(); >+ while (st.hasMoreTokens()) { >+ String s = st.nextToken().trim(); >+ keywords.add(s); >+ } >+ >+ return keywords; >+ // >+ // String[] keywords = >+ // getAttributeValue(BugzillaReportElement.KEYWORDS).split(","); >+ // return getAttributeValue(BugzillaReportElement.KEYWORDS) >+ // BugzillaPlugin.getDefault().getProductConfiguration(repository).getProducts() >+ // >+ // return >+ // BugzillaRepositoryUtil.getValidKeywords(this.getRepositoryUrl()); >+ } >+ >+ public String getLabel() { >+ return getId() + ": " + getAttributeValue(BugzillaReportElement.SHORT_DESC); >+ } >+ >+ public Date getLastModified() { >+ if (lastModified == null) { >+ String dateString = getAttributeValue(BugzillaReportElement.DELTA_TS); >+ try { >+ lastModified = df.parse(dateString); >+ } catch (Exception e) { >+ MylarStatusHandler >+ .fail(e, "Mylar: Unable to parse report #" + getId() + "'s modification date.", false); >+ } >+ } >+ return lastModified; >+ } >+ >+ /** >+ * Get the new comment that is to be added to the bug >+ * >+ * @return The new comment >+ */ >+ public String getNewComment() { >+ return newComment; >+ } >+ >+ // /** >+ // * @return the new value of the new NewComment. >+ // */ >+ // public String getNewNewComment() { >+ // return newNewComment; >+ // } >+ >+ /** >+ * Get an operation from the bug based on its display name >+ * >+ * @param displayText >+ * The display text for the operation >+ * @return The operation that has the display text >+ */ >+ public Operation getOperation(String displayText) { >+ Iterator<Operation> itr = operations.iterator(); >+ while (itr.hasNext()) { >+ Operation o = itr.next(); >+ String opName = o.getOperationName(); >+ opName = opName.replaceAll("</.*>", ""); >+ opName = opName.replaceAll("<.*>", ""); >+ if (opName.equals(displayText)) >+ return o; >+ } >+ return null; >+ } >+ >+ /** >+ * Get all of the operations that can be done to the bug >+ * >+ * @return The operations that can be done to the bug >+ */ >+ public List<Operation> getOperations() { >+ return operations; >+ } >+ >+ /** >+ * Get the person who reported the bug >+ * >+ * @return The person who reported the bug >+ */ >+ public String getReporter() { >+ return getAttributeValue(BugzillaReportElement.REPORTER); >+ } >+ >+ /** >+ * Get the resolution of the bug >+ * >+ * @return The resolution of the bug >+ */ >+ public String getResolution() { >+ return getAttributeValue(BugzillaReportElement.RESOLUTION); >+ } >+ >+ /** >+ * Get the status of the bug >+ * >+ * @return The bugs status >+ */ >+ public String getStatus() { >+ return getAttributeValue(BugzillaReportElement.BUG_STATUS); >+ } >+ >+ /** >+ * Get the summary for the bug >+ * >+ * @return The bugs summary >+ */ >+ public String getSummary() { >+ return getAttributeValue(BugzillaReportElement.SHORT_DESC); >+ } >+ >+ public void setSummary(String summary) { >+ setAttributeValue(BugzillaReportElement.SHORT_DESC, summary); >+ } >+ >+ public String getProduct() { >+ return getAttributeValue(BugzillaReportElement.PRODUCT); >+ } >+ >+ // public void setSummary(String newSummary) { >+ // setAttributeValue(BugzillaReportElement.SHORT_DESC, newSummary); >+ // } >+ >+ public boolean isLocallyCreated() { >+ return false; >+ } >+ >+ public boolean isResolved() { >+ AbstractRepositoryReportAttribute status = getAttribute(BugzillaReportElement.BUG_STATUS); >+ return status != null && isResolvedStatus(status.getValue()); >+ } >+ >+ public boolean isSavedOffline() { >+ return savedOffline; >+ } >+ >+ /** >+ * Remove an address from the bugs CC list >+ * >+ * @param email >+ * the address to be removed from the CC list >+ * @return <code>true</code> if the email is in the set and it was removed >+ */ >+ public void removeCC(String email) { >+ removeAttributeValue(BugzillaReportElement.CC, email); >+ } >+ >+ // /** >+ // * Set the bugs creation date >+ // * >+ // * @param created >+ // * The date the the bug was created >+ // */ >+ // public void setCreated(Date created) { >+ // this.created = created; >+ // } >+ >+ public void setDescription(String description) { >+ // ignore, used by NewBugReport >+ // this.description = decodeStringFromCharset(description); >+ } >+ >+ public void setKeywords(List<String> keywords) { >+ this.validKeywords = keywords; >+ } >+ >+ // public void setLastModified(Date date) { >+ // this.lastModified = date; >+ // } >+ >+ /** >+ * Set the new comment that will be added to the bug >+ * >+ * @param newComment >+ * The new comment to add to the bug >+ */ >+ public void setNewComment(String newComment) { >+ this.newComment = newComment; >+ // newNewComment = newComment; >+ } >+ >+ // /** >+ // * Set the new value of the new NewComment >+ // * >+ // * @param newNewComment >+ // * The new value of the new NewComment. >+ // */ >+ // public void setNewNewComment(String newNewComment) { >+ // this.newNewComment = newNewComment; >+ // } >+ >+ public void setOfflineState(boolean newOfflineState) { >+ savedOffline = newOfflineState; >+ } >+ >+ public void setSelectedOperation(Operation o) { >+ selectedOperation = o; >+ } >+ >+ public Operation getSelectedOperation() { >+ return selectedOperation; >+ } >+ >+ @Override >+ public AbstractAttributeFactory getAttributeFactory() { >+ return attributeFactory; >+ } >+ >+ public AbstractRepositoryReportAttribute getAttribute(String test) { >+ >+ MylarStatusHandler.fail(new Exception(), "BugReport: getAttribute called with string", false); >+ return new BugzillaReportAttribute(BugzillaReportElement.UNKNOWN); >+ } >+} >Index: src/org/eclipse/mylar/internal/bugzilla/core/internal/RepositoryReportFactory.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/bugzilla/core/internal/RepositoryReportFactory.java >diff -N src/org/eclipse/mylar/internal/bugzilla/core/internal/RepositoryReportFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/bugzilla/core/internal/RepositoryReportFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,188 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.bugzilla.core.internal; >+ >+import java.io.BufferedReader; >+import java.io.IOException; >+import java.io.InputStreamReader; >+import java.net.URL; >+import java.net.URLConnection; >+import java.nio.charset.Charset; >+ >+import javax.security.auth.login.LoginException; >+ >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; >+import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; >+import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >+import org.eclipse.mylar.provisional.tasklist.TaskRepository; >+import org.xml.sax.ErrorHandler; >+import org.xml.sax.InputSource; >+import org.xml.sax.SAXException; >+import org.xml.sax.SAXParseException; >+import org.xml.sax.XMLReader; >+import org.xml.sax.helpers.XMLReaderFactory; >+ >+/** >+ * Reads bug reports from repository. >+ * >+ * @author Rob Elves >+ */ >+public class RepositoryReportFactory { >+ >+ private static RepositoryReportFactory instance; >+ >+ private static final String SHOW_BUG_CGI_XML = "/show_bug.cgi?ctype=xml&id="; >+ >+ private static final String ATTR_CHARSET = "charset"; >+ >+ private RepositoryReportFactory() { >+ // no initial setup needed >+ } >+ >+ public static RepositoryReportFactory getInstance() { >+ if (instance == null) { >+ instance = new RepositoryReportFactory(); >+ } >+ return instance; >+ } >+ >+ // /** >+ // * Bugzilla specific, to be generalized >+ // * TODO: Based on repository kind use appropriate loader >+ // */ >+ // public AbstractRepositoryReport readReport(int id, TaskRepository >+ // repository) >+ // throws IOException, LoginException { >+ // BugReport bugReport = new BugReport(id, repository.getUrl()); >+ // SaxBugReportContentHandler contentHandler = new >+ // SaxBugReportContentHandler(bugReport); >+ // >+ // String xmlBugReportUrl = repository.getUrl() + SHOW_BUG_CGI_XML + id; >+ // >+ // URL serverURL = new URL(BugzillaRepositoryUtil.addCredentials(repository, >+ // xmlBugReportUrl)); >+ // URLConnection connection = serverURL.openConnection(); >+ // String contentType = connection.getContentType(); >+ // if (contentType != null) { >+ // String charsetFromContentType = getCharsetFromString(contentType); >+ // if (charsetFromContentType != null) { >+ // bugReport.setCharset(charsetFromContentType); >+ // } >+ // } >+ // >+ // BufferedReader in = new BufferedReader(new >+ // InputStreamReader(connection.getInputStream())); >+ // >+ // try { >+ // XMLReader reader = XMLReaderFactory.createXMLReader(); >+ // reader.setContentHandler(contentHandler); >+ // reader.setErrorHandler(new SaxErrorHandler()); >+ // reader.parse(new InputSource(in)); >+ // >+ // if(contentHandler.errorOccurred()) { >+ // throw new BugzillaReportParseException(contentHandler.getErrorMessage()); >+ // } >+ // >+ // } catch (SAXException e) { >+ // throw new IOException(e.getMessage()); >+ // } >+ // return bugReport; >+ // } >+ >+ /** >+ * Bugzilla specific, to be generalized TODO: Based on repository kind use >+ * appropriate loader >+ */ >+ public void populateReport(BugzillaReport bugReport, TaskRepository repository) throws IOException, LoginException { >+ >+ SaxBugReportContentHandler contentHandler = new SaxBugReportContentHandler(bugReport); >+ >+ String xmlBugReportUrl = repository.getUrl() + SHOW_BUG_CGI_XML + bugReport.getId(); >+ >+ URL serverURL = new URL(BugzillaRepositoryUtil.addCredentials(repository, xmlBugReportUrl)); >+ URLConnection connection = serverURL.openConnection(); >+ String contentType = connection.getContentType(); >+ if (contentType != null) { >+ String charsetFromContentType = getCharsetFromString(contentType); >+ if (charsetFromContentType != null) { >+ bugReport.setCharset(charsetFromContentType); >+ } >+ } >+ >+ BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); >+ >+ try { >+ XMLReader reader = XMLReaderFactory.createXMLReader(); >+ reader.setContentHandler(contentHandler); >+ reader.setErrorHandler(new SaxErrorHandler()); >+ reader.parse(new InputSource(in)); >+ >+ if (contentHandler.errorOccurred()) { >+ throw new BugzillaReportParseException(contentHandler.getErrorMessage()); >+ } >+ >+ } catch (SAXException e) { >+ throw new IOException(e.getMessage()); >+ } >+ } >+ >+ // TODO: pull up >+ public static String getCharsetFromString(String string) { >+ int charsetStartIndex = string.indexOf(ATTR_CHARSET); >+ if (charsetStartIndex != -1) { >+ int charsetEndIndex = string.indexOf("\"", charsetStartIndex); // TODO: >+ // could >+ // be >+ // space >+ // after? >+ if (charsetEndIndex == -1) { >+ charsetEndIndex = string.length(); >+ } >+ String charsetString = string.substring(charsetStartIndex + 8, charsetEndIndex); >+ if (Charset.availableCharsets().containsKey(charsetString)) { >+ return charsetString; >+ } >+ } >+ return null; >+ } >+ >+ class SaxErrorHandler implements ErrorHandler { >+ >+ public void error(SAXParseException exception) throws SAXException { >+ System.err.println("Error: " + exception.getLineNumber() + "\n" + exception.getLocalizedMessage()); >+ >+ } >+ >+ public void fatalError(SAXParseException exception) throws SAXException { >+ // System.err.println("Fatal Error: " + exception.getLineNumber() + >+ // "\n" + exception.getLocalizedMessage()); >+ // TODO: Need to determine actual error from html >+ throw new SAXException(IBugzillaConstants.ERROR_INVALID_USERNAME_OR_PASSWORD); >+ } >+ >+ public void warning(SAXParseException exception) throws SAXException { >+ System.err.println("Warning: " + exception.getLineNumber() + "\n" + exception.getLocalizedMessage()); >+ >+ } >+ >+ } >+ >+ public class BugzillaReportParseException extends IOException { >+ >+ private static final long serialVersionUID = 7269179766737288564L; >+ >+ public BugzillaReportParseException(String message) { >+ super(message); >+ } >+ } >+ >+} >Index: src/org/eclipse/mylar/bugzilla/core/AttributeContainer.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/core/AttributeContainer.java >diff -N src/org/eclipse/mylar/bugzilla/core/AttributeContainer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/bugzilla/core/AttributeContainer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,73 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.core; >+ >+import java.io.Serializable; >+import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+ >+public class AttributeContainer implements Serializable { >+ >+ private static final long serialVersionUID = -3990742719133977940L; >+ >+ /** The keys for the report attributes */ >+ private ArrayList<Object> attributeKeys; >+ >+ /** report attributes (status, resolution, etc.) */ >+ private HashMap<Object, AbstractRepositoryReportAttribute> attributes; >+ >+ public AttributeContainer() { >+ attributeKeys = new ArrayList<Object>(); >+ attributes = new HashMap<Object, AbstractRepositoryReportAttribute>(); >+ } >+ >+ public void addAttribute(Object key, AbstractRepositoryReportAttribute attribute) { >+ if (!attributes.containsKey(attribute.getName())) { >+ attributeKeys.add(key); >+ } >+ >+ // TODO: deal with character sets >+ //attribute.setValue(decodeStringFromCharset(attribute.getValue())); >+ >+ attributes.put(key, attribute); >+ } >+ >+ public AbstractRepositoryReportAttribute getAttribute(Object key) { >+ return attributes.get(key); >+ } >+ >+ public void removeAttribute(Object key) { >+ attributeKeys.remove(key); >+ attributes.remove(key); >+ } >+ >+ public List<AbstractRepositoryReportAttribute> getAttributes() { >+ ArrayList<AbstractRepositoryReportAttribute> attributeEntries = new ArrayList<AbstractRepositoryReportAttribute>( >+ attributeKeys.size()); >+ for (Iterator<Object> it = attributeKeys.iterator(); it.hasNext();) { >+ Object key = it.next(); >+ AbstractRepositoryReportAttribute attribute = attributes.get(key); >+ attributeEntries.add(attribute); >+ } >+ return attributeEntries; >+ } >+ >+ public String getAttributeValue(Object key) { >+ AbstractRepositoryReportAttribute attribute = getAttribute(key); >+ if(attribute != null) { >+ return attribute.getValue(); >+ } >+ return ""; >+ } >+} >#P org.eclipse.mylar.tests >Index: src/org/eclipse/mylar/tests/misc/AllMiscTests.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tests/src/org/eclipse/mylar/tests/misc/AllMiscTests.java,v >retrieving revision 1.4 >diff -u -r1.4 AllMiscTests.java >--- src/org/eclipse/mylar/tests/misc/AllMiscTests.java 28 Feb 2006 01:14:43 -0000 1.4 >+++ src/org/eclipse/mylar/tests/misc/AllMiscTests.java 8 May 2006 23:07:25 -0000 >@@ -26,7 +26,7 @@ > // suite.addTestSuite(BugzillaSearchPluginTest.class); > suite.addTestSuite(AssertionsEnabledTest.class); > suite.addTestSuite(HypertextStructureBridgeTest.class); >- suite.addTestSuite(BugzillaStackTraceTest.class); >+ //suite.addTestSuite(BugzillaStackTraceTest.class); > // $JUnit-END$ > return suite; > } >Index: src/org/eclipse/mylar/tests/misc/BugzillaStackTraceTest.java >=================================================================== >RCS file: src/org/eclipse/mylar/tests/misc/BugzillaStackTraceTest.java >diff -N src/org/eclipse/mylar/tests/misc/BugzillaStackTraceTest.java >--- src/org/eclipse/mylar/tests/misc/BugzillaStackTraceTest.java 11 Mar 2006 03:53:58 -0000 1.10 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,196 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >-////Created on Oct 12, 2004 >-package org.eclipse.mylar.tests.misc; >- >-import java.io.File; >-import java.io.FileReader; >-import java.io.Reader; >-import java.util.ArrayList; >-import java.util.List; >- >-import junit.framework.TestCase; >- >-import org.eclipse.core.runtime.Path; >-import org.eclipse.mylar.bugzilla.tests.BugzillaTestPlugin; >-import org.eclipse.mylar.core.tests.support.FileTool; >-import org.eclipse.mylar.internal.bugs.search.BugzillaMylarSearchOperation; >-import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser; >-import org.eclipse.mylar.internal.bugzilla.core.search.BugzillaSearchHit; >-import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaReportNode; >-import org.eclipse.mylar.internal.bugzilla.ui.tasklist.StackTrace; >- >-/** >- * Class to test the Bridge methods that do not require server queries >- * >- * @author Shawn Minto >- */ >-public class BugzillaStackTraceTest extends TestCase { >- >- private static final String TEST_FILE_LOC = "testdata/reports-stacktrace/"; >- >- private static final String BUGZILLA_SERVER_NAME = "https://bugs.eclipse.org/bugs"; >- >- /** >- * Test that the regular expression escaping mechanism works properly >- */ >- public void testREGEX() { >- String r = ".*+(){}[]^$|?/\\"; >- String r2 = StackTrace.escapeForRegex(r); >- String ans = "\\.\\*\\+\\(\\)\\{\\}\\[\\]\\^\\$\\|\\?\\/\\\\"; >- String msg = "Regular Expression matching wrong:\nwas: " + r2 + "\nshould be:" + ans; >- assertTrue(msg, r2.equals(ans)); >- } >- >- // /** >- // * Test parsing the bug for multiple stacks in in >- // */ >- // public void testMultipleStacksDiffComments(){ >- // // REPORT_REPOSITORY 4862 - 2 stack traces - 1 in description, 1 in >- // comment - text >- // before and after >- // performParse(4862, "4862.html", 2, false); >- // } >- >- // /** >- // * Test parsing the bug for a single stack in the description with some >- // * text before it >- // */ >- // public void testSingleStackCodeBeforeInDescription(){ >- // // REPORT_REPOSITORY 76388 - 1 stack trace - description - text before >- // and formatted >- // ugly >- // performParse(76388, "76388.html", 1, false); >- // } >- >- /** >- * Test parsing the bug for a single stack trace in the description with >- * text before and after it >- */ >- public void testSingleStackCodeBeforeAndAfterInDescription() { >- >- // REPORT_REPOSITORY 76146 - 1 stack trace - description - text before >- // and code after >- performParse(76146, "76146.html", 1, false); >- } >- >- /** >- * Test parsing a bug that has 1 stack trace in the description with no >- * extra text, but has lines in it that span 3 lines >- */ >- public void testSingleStackPoorFormatInDescription() { >- // REPORT_REPOSITORY 67395 - 1 stack trace - description - no extra >- // text, 1 at line >- // spans 3 lines >- performParse(67395, "67395.html", 1, false); >- } >- >- /** >- * Test parsing a bug with no stack traces and no qualified exception names >- */ >- public void testNoStackNoQualified() { >- // REPORT_REPOSITORY 4548 - no stack traces, no qualified reference to >- // an exception >- performParse(4548, "4548.html", 0, false); >- } >- >- /** >- * Test parsing a bug with no stack traces, but a qualified reference to an >- * exception >- */ >- public void testNoStackQual() { >- // REPORT_REPOSITORY 1 - no stack traces, qualified reference to >- // exception - made up >- // bug >- performParse(1, "1.html", 0, false); >- } >- >- /** >- * Test parsing of a bug with 1 stack trace and multiple qualified >- * references >- */ >- public void testSingleStackQual() { >- // REPORT_REPOSITORY 2 - 1 stack trace- 2 qual ref, stack trace, 1 qual >- // ref - made up >- // bug >- performParse(2, "2.html", 1, false); >- } >- >- /** >- * Test parsing of a bug with many stacks traces in a single comment >- */ >- public void testMultipleStackSingleComment() { >- // REPORT_REPOSITORY 40152 - 1 stack trace- 2 qual ref, stack trace, 1 >- // qual ref - made >- // up bug >- performParse(40152, "40152.html", 33, false); >- } >- >- /** >- * Print out the stack traces >- * >- * @param l >- * List of stack traces >- */ >- private void printStackTraces(List<StackTrace> l) { >- System.out.println("\n\n"); >- for (int i = 0; i < l.size(); i++) { >- StackTrace trace = l.get(i); >- System.out.println("*****************?????????????????*****************\n"); >- System.out.println("OFFSET: " + trace.getOffset() + " LENGTH: " + trace.getLength()); >- System.out.println(trace.getStackTrace()); >- System.out.println("*****************?????????????????*****************\n\n"); >- } >- } >- >- private void performParse(int bugNumber, String bugFileName, int numTracesExpected, boolean printStackTraces) { >- >- BugzillaSearchHit hit = new BugzillaSearchHit("<TEST-SERVER>", bugNumber, "", "", "", "", "", "", "", ""); // stack >- // trace >- // in >- // desc >- // and >- // com >- >- // create a new doi info >- BugzillaReportNode doi = new BugzillaReportNode(0, hit, false); >- try { >- >- // read the bug in from a file >- File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path(TEST_FILE_LOC + bugFileName)); // used >- // if >- // run >- // as a >- // plugin >- // test >- // File f = new File(TEST_FILE_LOC+bugFileName); // used if run as a >- // standalone test >- Reader reader = new FileReader(f); >- doi.setBug(BugParser.parseBug(reader, hit.getId(), BUGZILLA_SERVER_NAME, true, null, null, null)); >- reader.close(); >- } catch (Exception e) { >- e.printStackTrace(); >- } >- >- // do a second pass parse on the bug >- List<BugzillaReportNode> l = new ArrayList<BugzillaReportNode>(); >- l.add(doi); >- BugzillaMylarSearchOperation.secondPassBugzillaParser(l); >- >- // make sure that we received the right number of stack traces back >- // System.out.println("*** REPORT_REPOSITORY " + hit.getId() + " ***"); >- // System.out.println("NumStackTraces = " + >- // doi.getStackTraces().size()); >- assertEquals("Wrong Number stack traces", numTracesExpected, doi.getStackTraces().size()); >- if (printStackTraces) >- printStackTraces(doi.getStackTraces()); >- } >-} >#P org.eclipse.mylar >Index: developer/scratch/bugzilla/BugzillaParserTestNoBug.java >=================================================================== >RCS file: developer/scratch/bugzilla/BugzillaParserTestNoBug.java >diff -N developer/scratch/bugzilla/BugzillaParserTestNoBug.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ developer/scratch/bugzilla/BugzillaParserTestNoBug.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * Copyright (c) 2003 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.mylar.bugzilla.tests; >+ >+import java.io.File; >+import java.io.FileReader; >+import java.io.Reader; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.core.runtime.Path; >+import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.core.tests.support.FileTool; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser; >+ >+/** >+ * Tests for parsing Bugzilla reports >+ */ >+public class BugzillaParserTestNoBug extends TestCase { >+ >+ public BugzillaParserTestNoBug() { >+ super(); >+ } >+ >+ public BugzillaParserTestNoBug(String arg0) { >+ super(arg0); >+ } >+ >+ public void testBugNotFound() throws Exception { >+ >+ File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( >+ "testdata/pages/bug-not-found-eclipse.html")); >+ >+ Reader in = new FileReader(f); >+ >+ BugReport bug = BugParser.parseBug(in, 666, "<server>", false, null, null, null); >+ assertNull(bug); >+ } >+} >Index: developer/scratch/bugzilla/BugzillaNewBugParserTestVE.java >=================================================================== >RCS file: developer/scratch/bugzilla/BugzillaNewBugParserTestVE.java >diff -N developer/scratch/bugzilla/BugzillaNewBugParserTestVE.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ developer/scratch/bugzilla/BugzillaNewBugParserTestVE.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,225 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.tests; >+ >+import java.io.File; >+import java.io.FileReader; >+import java.io.Reader; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.core.runtime.Path; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.core.tests.support.FileTool; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; >+import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; >+ >+/** >+ * Tests NewBugParser -- parses product attributes >+ */ >+public class BugzillaNewBugParserTestVE extends TestCase { >+ >+ public BugzillaNewBugParserTestVE() { >+ super(); >+ } >+ >+ public BugzillaNewBugParserTestVE(String arg0) { >+ super(arg0); >+ } >+ >+ public void testProductVE() throws Exception { >+ File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/ve-page.html")); >+ >+ Reader in = new FileReader(f); >+ >+ NewBugzillaReport nbm = new NewBugzillaReport(); >+ new NewBugParser(in).parseBugAttributes(nbm, true); // ** TRUE vs FALSE >+ // ** >+ >+ // attributes for this but model >+ List<AbstractRepositoryReportAttribute> attributes = nbm.getAttributes(); >+ // printList(attributes); >+ >+ Iterator<AbstractRepositoryReportAttribute> itr = attributes.iterator(); >+ AbstractRepositoryReportAttribute att = itr.next(); >+ >+ // Attribute: Severity >+ assertEquals("Attribute: Severity", "Severity", att.getName()); >+ >+ Map<String, String> attOptions = att.getOptionValues(); // HashMap of >+ // options for the >+ // current >+ // attribute >+ Object[] options = attOptions.keySet().toArray(); // Array of keys for >+ // the options of the >+ // current attribute >+ assertEquals("# Severity options", 7, options.length); >+ >+ int i = 0; >+ while (i < options.length) { >+ assertEquals("severity options", "blocker", options[i++]); >+ assertEquals("severity options", "critical", options[i++]); >+ assertEquals("severity options", "major", options[i++]); >+ assertEquals("severity options", "normal", options[i++]); >+ assertEquals("severity options", "minor", options[i++]); >+ assertEquals("severity options", "trivial", options[i++]); >+ assertEquals("severity options", "enhancement", options[i++]); >+ } >+ >+ // Attribute: product >+ att = itr.next(); >+ assertEquals("Attribute: product", "product", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("No product options", 0, options.length); >+ >+ // Attribute: AssignedTo >+ att = itr.next(); >+ assertEquals("Attribute: AssignedTo", "AssignedTo", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("No AssignedTo options", 0, options.length); >+ >+ // Attribute: OS >+ att = itr.next(); >+ assertEquals("Attribute: OS", "OS", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("# of options", 20, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("OS options", "All", options[i++]); >+ assertEquals("OS options", "AIX Motif", options[i++]); >+ assertEquals("OS options", "Windows 95", options[i++]); >+ assertEquals("OS options", "Windows 98", options[i++]); >+ assertEquals("OS options", "Windows CE", options[i++]); >+ assertEquals("OS options", "Windows ME", options[i++]); >+ assertEquals("OS options", "Windows 2000", options[i++]); >+ assertEquals("OS options", "Windows NT", options[i++]); >+ assertEquals("OS options", "Windows XP", options[i++]); >+ assertEquals("OS options", "Windows All", options[i++]); >+ assertEquals("OS options", "MacOS X", options[i++]); >+ assertEquals("OS options", "Linux", options[i++]); >+ assertEquals("OS options", "Linux-GTK", options[i++]); >+ assertEquals("OS options", "Linux-Motif", options[i++]); >+ assertEquals("OS options", "HP-UX", options[i++]); >+ assertEquals("OS options", "Neutrino", options[i++]); >+ assertEquals("OS options", "QNX-Photon", options[i++]); >+ assertEquals("OS options", "Solaris", options[i++]); >+ assertEquals("OS options", "Unix All", options[i++]); >+ assertEquals("OS options", "other", options[i++]); >+ } >+ >+ // Attribute: Version >+ att = itr.next(); >+ assertEquals("Attribute: Version", "Version", att.getName()); >+ >+ // attOptions = (HashMap) att.getOptionValues(); >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# Version options", 3, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Version options", "0.5.0", options[i++]); >+ assertEquals("Version options", "1.0.0", options[i++]); >+ assertEquals("Version options", "unspecified", options[i++]); >+ } >+ >+ // Attribute: Platform >+ att = itr.next(); >+ assertEquals("Attribute: Platform", "Platform", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# Platform options", 6, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Platform options", "All", options[i++]); >+ assertEquals("Platform options", "Macintosh", options[i++]); >+ assertEquals("Platform options", "PC", options[i++]); >+ assertEquals("Platform options", "Power PC", options[i++]); >+ assertEquals("Platform options", "Sun", options[i++]); >+ assertEquals("Platform options", "Other", options[i++]); >+ } >+ >+ att = itr.next(); >+ assertEquals("Attribute: Component", "Component", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# Component options", 6, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Component options", "CDE", options[i++]); >+ assertEquals("Component options", "Doc", options[i++]); >+ assertEquals("Component options", "Java Core", options[i++]); >+ assertEquals("Component options", "Java Model (JEM)", options[i++]); >+ assertEquals("Component options", "JFC/Swing", options[i++]); >+ assertEquals("Component options", "SWT", options[i++]); >+ } >+ >+ // Attribute: bug_status >+ att = itr.next(); >+ assertEquals("Attribute: bug_status", "bug_status", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No bug_status options", 0, options.length); >+ >+ // Attribute: form_name >+ att = itr.next(); >+ assertEquals("Attribute: form_name", "form_name", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No form_name options", 0, options.length); >+ >+ // Attribute: bug_file_loc >+ att = itr.next(); >+ assertEquals("Attribute: bug_file_loc", "bug_file_loc", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No bug_file_loc options", 0, options.length); >+ >+ // Attribute: priority >+ att = itr.next(); >+ assertEquals("Attribute: priority", "priority", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No priority options", 0, options.length); >+ >+ } >+ >+ // private void printList(List<Attribute> attributes) { >+ // >+ // Iterator<Attribute> itr = attributes.iterator(); >+ // System.out.println("Attributes for this Product:"); >+ // System.out.println("============================"); >+ // >+ // while (itr.hasNext()) { >+ // Attribute attr = itr.next(); >+ // System.out.println(); >+ // System.out.println(attr.getName() + ": "); >+ // System.out.println("-----------"); >+ // >+ // Map<String, String> options = attr.getOptionValues(); >+ // Object[] it = options.keySet().toArray(); >+ // for (int i = 0; i < it.length; i++) >+ // System.out.println((String) it[i]); >+ // } >+ // } >+} >Index: developer/scratch/bugzilla/BugzillaNewBugParserTestPlatform.java >=================================================================== >RCS file: developer/scratch/bugzilla/BugzillaNewBugParserTestPlatform.java >diff -N developer/scratch/bugzilla/BugzillaNewBugParserTestPlatform.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ developer/scratch/bugzilla/BugzillaNewBugParserTestPlatform.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,246 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.tests; >+ >+import java.io.File; >+import java.io.FileReader; >+import java.io.Reader; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.core.runtime.Path; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.core.tests.support.FileTool; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; >+import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; >+ >+/** >+ * Tests NewBugParser -- parses product attributes >+ */ >+public class BugzillaNewBugParserTestPlatform extends TestCase { >+ >+ public BugzillaNewBugParserTestPlatform() { >+ super(); >+ } >+ >+ public BugzillaNewBugParserTestPlatform(String arg0) { >+ super(arg0); >+ } >+ >+ public void testProductPlatform() throws Exception { >+ >+ File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), >+ new Path("testdata/pages/platform-page.html")); >+ >+ Reader in = new FileReader(f); >+ >+ NewBugzillaReport nbm = new NewBugzillaReport(); >+ new NewBugParser(in).parseBugAttributes(nbm, true); // ** TRUE vs FALSE >+ // ** >+ >+ // attributes for this bug model >+ List<AbstractRepositoryReportAttribute> attributes = nbm.getAttributes(); >+ // printList(attributes); >+ >+ // to iterator over the ArrayList of attributes >+ Iterator<AbstractRepositoryReportAttribute> itr = attributes.iterator(); >+ >+ // Attribute: Severity >+ AbstractRepositoryReportAttribute att = itr.next(); // current attribute >+ >+ // Attribute: Severity >+ assertEquals("Attribute: Severity", "Severity", att.getName()); >+ >+ Map<String, String> attOptions = att.getOptionValues(); // HashMap of >+ // options for the >+ // current >+ // attribute >+ Object[] options = attOptions.keySet().toArray(); // Array of keys for >+ // the options of the >+ // current attribute >+ assertEquals("# Severity options", 7, options.length); >+ >+ int i = 0; >+ while (i < options.length) { >+ assertEquals("severity options", "blocker", options[i++]); >+ assertEquals("severity options", "critical", options[i++]); >+ assertEquals("severity options", "major", options[i++]); >+ assertEquals("severity options", "normal", options[i++]); >+ assertEquals("severity options", "minor", options[i++]); >+ assertEquals("severity options", "trivial", options[i++]); >+ assertEquals("severity options", "enhancement", options[i++]); >+ } >+ >+ // Attribute: product >+ att = itr.next(); >+ assertEquals("Attribute: product", "product", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("No product optins", 0, options.length); >+ >+ // Attribute: AssignedTo >+ att = itr.next(); >+ assertEquals("Attribute: Assigned To", "Assigned To", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No AssingedTo options", 0, options.length); >+ >+ // Attribute: OS >+ att = itr.next(); >+ assertEquals("Attribute: OS", "OS", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("# OS options", 20, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("OS options", "All", options[i++]); >+ assertEquals("OS options", "AIX Motif", options[i++]); >+ assertEquals("OS options", "Windows 95", options[i++]); >+ assertEquals("OS options", "Windows 98", options[i++]); >+ assertEquals("OS options", "Windows CE", options[i++]); >+ assertEquals("OS options", "Windows ME", options[i++]); >+ assertEquals("OS options", "Windows 2000", options[i++]); >+ assertEquals("OS options", "Windows NT", options[i++]); >+ assertEquals("OS options", "Windows XP", options[i++]); >+ assertEquals("OS options", "Windows All", options[i++]); >+ assertEquals("OS options", "MacOS X", options[i++]); >+ assertEquals("OS options", "Linux", options[i++]); >+ assertEquals("OS options", "Linux-GTK", options[i++]); >+ assertEquals("OS options", "Linux-Motif", options[i++]); >+ assertEquals("OS options", "HP-UX", options[i++]); >+ assertEquals("OS options", "Neutrino", options[i++]); >+ assertEquals("OS options", "QNX-Photon", options[i++]); >+ assertEquals("OS options", "Solaris", options[i++]); >+ assertEquals("OS options", "Unix All", options[i++]); >+ assertEquals("OS options", "other", options[i++]); >+ } >+ >+ // Attribute: Version >+ att = itr.next(); >+ assertEquals("Attribute: Version", "Version", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("# Version options", 8, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Version options", "1.0", options[i++]); >+ assertEquals("Version options", "2.0", options[i++]); >+ assertEquals("Version options", "2.0.1", options[i++]); >+ assertEquals("Version options", "2.0.2", options[i++]); >+ assertEquals("Version options", "2.1", options[i++]); >+ assertEquals("Version options", "2.1.1", options[i++]); >+ assertEquals("Version options", "2.1.2", options[i++]); >+ assertEquals("Version options", "3.0", options[i++]); >+ } >+ >+ // Attribute: Platform >+ att = itr.next(); >+ assertEquals("Attribute: Platform", "Platform", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# Platform options", 6, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Platform options", "All", options[i++]); >+ assertEquals("Platform options", "Macintosh", options[i++]); >+ assertEquals("Platform options", "PC", options[i++]); >+ assertEquals("Platform options", "Power PC", options[i++]); >+ assertEquals("Platform options", "Sun", options[i++]); >+ assertEquals("Platform options", "Other", options[i++]); >+ } >+ >+ // Attribute: Component >+ att = itr.next(); >+ assertEquals("Attribute: Component", "Component", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("# Component options", 16, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Component options", "Ant", options[i++]); >+ assertEquals("Component options", "Compare", options[i++]); >+ assertEquals("Component options", "Core", options[i++]); >+ assertEquals("Component options", "CVS", options[i++]); >+ assertEquals("Component options", "Debug", options[i++]); >+ assertEquals("Component options", "Doc", options[i++]); >+ assertEquals("Component options", "Help", options[i++]); >+ assertEquals("Component options", "Releng", options[i++]); >+ assertEquals("Component options", "Scripting", options[i++]); >+ assertEquals("Component options", "Search", options[i++]); >+ assertEquals("Component options", "SWT", options[i++]); >+ assertEquals("Component options", "Team", options[i++]); >+ assertEquals("Component options", "Text", options[i++]); >+ assertEquals("Component options", "UI", options[i++]); >+ assertEquals("Component options", "Update", options[i++]); >+ assertEquals("Component options", "WebDAV", options[i++]); >+ } >+ >+ // Attribute: bug_status >+ att = itr.next(); >+ assertEquals("Attribute: bug_status", "bug_status", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("No bug_status options", 0, options.length); >+ >+ // Attribute: form_name >+ att = itr.next(); >+ assertEquals("Attribute: form_name", "form_name", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No form_name options", 0, options.length); >+ >+ // Attribute: bug_file_loc >+ att = itr.next(); >+ assertEquals("Attribute: bug_file_loc", "bug_file_loc", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No bug_file_loc options", 0, options.length); >+ >+ // Attribute: priority >+ att = itr.next(); >+ assertEquals("Attribute: priority", "priority", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No priority options", 0, options.length); >+ } >+ >+ // private void printList(List<Attribute> attributes) { >+ // >+ // Iterator<Attribute> itr = attributes.iterator(); >+ // System.out.println("Attributes for this Product:"); >+ // System.out.println("============================"); >+ // >+ // while (itr.hasNext()) { >+ // Attribute attr = itr.next(); >+ // System.out.println(); >+ // System.out.println(attr.getName() + ": "); >+ // System.out.println("-----------"); >+ // >+ // Map<String, String> options = attr.getOptionValues(); >+ // Object[] it = options.keySet().toArray(); >+ // for (int i = 0; i < it.length; i++) >+ // System.out.println((String) it[i]); >+ // } >+ // } >+} >Index: developer/scratch/bugzilla/BugzillaParserTest.java >=================================================================== >RCS file: developer/scratch/bugzilla/BugzillaParserTest.java >diff -N developer/scratch/bugzilla/BugzillaParserTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ developer/scratch/bugzilla/BugzillaParserTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,196 @@ >+/******************************************************************************* >+ * Copyright (c) 2003 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.mylar.bugzilla.tests; >+ >+import java.io.File; >+import java.io.FileReader; >+import java.io.Reader; >+import java.util.Iterator; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.core.runtime.Path; >+import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.Comment; >+import org.eclipse.mylar.core.tests.support.FileTool; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser; >+ >+/** >+ * Tests for parsing Bugzilla reports >+ */ >+public class BugzillaParserTest extends TestCase { >+ >+ public BugzillaParserTest() { >+ super(); >+ } >+ >+ public BugzillaParserTest(String arg0) { >+ super(arg0); >+ } >+ >+ public void testFullReportBug1() throws Exception { >+ >+ File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/bug-1-full.html")); >+ >+ Reader in = new FileReader(f); >+ >+ BugReport bug = BugParser.parseBug(in, 1, "<server>", false, null, null, null); >+ >+ // displayBug(bug); >+ assertEquals("Bug id", 1, bug.getId()); >+ assertEquals("Bug summary", "Usability issue with external editors (1GE6IRL)", bug.getSummary()); >+ assertEquals("Reporter", "andre_weinand@ch.ibm.com (Andre Weinand)", bug.getReporter()); >+ assertEquals("Reporter", "andre_weinand@ch.ibm.com (Andre Weinand)", bug.getAttribute("Reporter").getValue()); >+ assertEquals("Summary", "Usability issue with external editors (1GE6IRL)", bug.getSummary()); >+ assertEquals("Status", "VERIFIED", bug.getStatus()); >+ assertEquals("Resolution", "FIXED", bug.getResolution()); >+ assertEquals("Keywords", null, bug.getKeywords()); >+ assertEquals("Assigned To", "James_Moody@ca.ibm.com (James Moody)", bug.getAssignedTo()); >+ assertEquals("Priority", "P3", bug.getAttribute("Priority").getValue()); >+ assertEquals("OS", "All", bug.getAttribute("OS").getValue()); >+ assertEquals("Version", "2.0", bug.getAttribute("Version").getValue()); >+ assertEquals("Target Milestone", "---", bug.getAttribute("Target Milestone").getValue()); >+ assertEquals("Keywords", "", bug.getAttribute("Keywords").getValue()); >+ assertEquals("Severity", "normal", bug.getAttribute("Severity").getValue()); >+ assertEquals("Component", "VCM", bug.getAttribute("Component").getValue()); >+ assertEquals("CC", "Kevin_McGuire@oti.com", bug.getCC().iterator().next()); >+ assertEquals("Platform", "All", bug.getAttribute("Platform").getValue()); >+ assertEquals("Product", "Platform", bug.getAttribute("Product").getValue()); >+ assertEquals("URL", "", bug.getAttribute("URL").getValue()); >+ assertEquals("Bug#", "1", bug.getAttribute("Bug#").getValue()); >+ >+ // Description >+ String description = "- Setup a project that contains a *.gif resource\n" >+ + "\t- release project to CVS\n" >+ + "\t- edit the *.gif resource with an external editor, e.g. PaintShop\n" >+ + "\t- save and close external editor\n" >+ + "\t- in Navigator open the icon resource and verify that your changes are there\n" >+ + "\t- release project\n" >+ + "\t\t-> nothing to release!\n" >+ + "\t- in Navigator open the icon resource and verify that your changes are still there\n\n" >+ + >+ >+ "\tProblem: because I never \"Refreshed from local\", the workspace hasn't changed so \"Release\" didn't find anything.\n" >+ + "\tHowever opening the resource with an external editor found the modified file on disk and showed the changes.\n\n" >+ + >+ >+ "\tThe real problem occurs if \"Release\" actually finds something to release but you don't spot that some resources are missing.\n" >+ + "\tThis is extremely error prone: one of my changes didn't made it into build 110 because of this!\n\n" >+ + >+ >+ "NOTES:\n" >+ + "EG (5/23/01 3:00:33 PM)\n" >+ + "\tRelease should do a refresh from local before doing the release.\n" >+ + "\tMoving to VCM\n\n\n" >+ + >+ >+ "KM (05/27/01 5:10:19 PM)\n" >+ + "\tComments from JM in related email:\n\n" >+ + >+ >+ "\tShould not do this for free. Could have a setting which made it optoinal but should nt be mandatory. Default setting could be to have it on.\n" >+ + "\tConsider the SWT team who keep their workspaces on network drives. This will be slow. \n\n" >+ + >+ >+ "\tSide effects will be that a build runs when the refresh is completed unless you somehow do it in a workspace runnable and don't end the\n" >+ + "\trunnable until after the release. This would be less than optimal as some builders may be responsible for maintaining some invariants and deriving resources which are releasable. If you don't run the builders before releasing, the invariants will not be maintained and you will release inconsistent state.\n\n" >+ + >+ >+ "\tSummary: Offer to \"ensure local consistency\" before releasing.\n\n" + >+ >+ "KM (5/31/01 1:30:35 PM)\n" >+ + "\tSee also 1GEAG1A: ITPVCM:WINNT - Internal error comparing with a document\n" >+ + "\twhich failed with an error. Never got log from Tod though."; >+ >+ assert (description.length() == bug.getDescription().length()); >+ assertEquals("Description", description, bug.getDescription()); >+ >+ // Comments: >+ Iterator<Comment> it = bug.getComments().iterator(); >+ while (it.hasNext()) { >+ // COMMENT #1 >+ Comment comment = it.next(); >+ assertEquals("Author1", "James_Moody@ca.ibm.com", comment.getAuthor()); >+ assertEquals("Name1", "James Moody", comment.getAuthorName()); >+ assertEquals("Text1", "*** Bug 183 has been marked as a duplicate of this bug. ***", comment.getText()); >+ >+ // COMMENT #2 >+ comment = it.next(); >+ assertEquals("Author2", "James_Moody@ca.ibm.com", comment.getAuthor()); >+ assertEquals("Name2", "James Moody", comment.getAuthorName()); >+ assertEquals("Text2", "Implemented 'auto refresh' option. Default value is off.", comment.getText()); >+ >+ // COMMENT 3 >+ comment = it.next(); >+ assertEquals("Author3", "dj_houghton@ca.ibm.com", comment.getAuthor()); >+ assertEquals("Name3", "DJ Houghton", comment.getAuthorName()); >+ assertEquals("Text3", "PRODUCT VERSION:\n\t109\n\n", comment.getText()); >+ >+ // COMMENT 4 >+ comment = it.next(); >+ assertEquals("Author4", "James_Moody@ca.ibm.com", comment.getAuthor()); >+ assertEquals("Name4", "James Moody", comment.getAuthorName()); >+ assertEquals("Text4", "Fixed in v206", comment.getText()); >+ } >+ } >+ >+ // private static void displayBug(BugReport bug) { >+ // System.out.println("Bug " + bug.getId() + ": " + bug.getSummary()); >+ // System.out.println("Opened: " + bug.getCreated()); >+ // for (Iterator<Attribute> it = bug.getAttributes().iterator(); >+ // it.hasNext();) { >+ // Attribute attribute = it.next(); >+ // String key = attribute.getName(); >+ // System.out.println(key + ": " + attribute.getValue() >+ // + (attribute.isEditable() ? " [OK]" : " %%")); >+ // } >+ // >+ // System.out.print("CC: "); >+ // for (Iterator<String> it = bug.getCC().iterator(); it.hasNext();) { >+ // String email = it.next(); >+ // System.out.print(email + " "); >+ // } >+ // System.out.println(); >+ // >+ // System.out.println(bug.getDescription()); >+ // for (Iterator<Comment> it = bug.getComments().iterator(); it.hasNext();) >+ // { >+ // Comment comment = it.next(); >+ // System.out.println(comment.getAuthorName() + " <" >+ // + comment.getAuthor() + "> (" + comment.getCreated() + ")"); >+ // System.out.print(comment.getText()); >+ // System.out.println(); >+ // } >+ // } >+ // >+ // private static void printComments(BugReport bug) { >+ // for (Iterator<Comment> it = bug.getComments().iterator(); it.hasNext();) >+ // { >+ // Comment comment = it.next(); >+ // System.out.println("Author: " + comment.getAuthor()); >+ // System.out.println("Name: " + comment.getAuthorName()); >+ // System.out.println("Date: " + comment.getCreated()); >+ // System.out.println("Bug ID: " + comment.getBug().getId()); >+ // System.out.println("Comment: " + comment.getText()); >+ // System.out.println(); >+ // } >+ // } >+ // >+ // /** prints names of attributes */ >+ // private static void printAttributes(BugReport bug) { >+ // System.out.println("ATTRIBUTE KEYS:"); >+ // for (Iterator<Attribute> it = bug.getAttributes().iterator(); >+ // it.hasNext();) { >+ // Attribute att = it.next(); >+ // System.out.println(att.getName()); >+ // } >+ // } >+} >Index: developer/scratch/bugzilla/Bugzilla220ParserTest.java >=================================================================== >RCS file: developer/scratch/bugzilla/Bugzilla220ParserTest.java >diff -N developer/scratch/bugzilla/Bugzilla220ParserTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ developer/scratch/bugzilla/Bugzilla220ParserTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,92 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.tests; >+ >+import java.io.File; >+import java.io.FileReader; >+import java.io.Reader; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.core.runtime.Path; >+import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.core.tests.support.FileTool; >+import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser; >+import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; >+ >+/** >+ * @author Mik Kersten >+ * @author Rob Elves >+ */ >+public class Bugzilla220ParserTest extends TestCase { >+ >+ public static final String TEST_SERVER = IBugzillaConstants.ECLIPSE_BUGZILLA_URL; >+ >+ private static final String PRODUCT_MYLAR = "Mylar"; >+ >+ private static final String PRODUCT_TEST = "TestProduct"; >+ >+ public void testId220() throws Exception { >+ >+ File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( >+ "testdata/pages/test-report-220.html")); >+ Reader in = new FileReader(f); >+ >+ BugReport bug = BugParser.parseBug(in, 7, TEST_SERVER, false, null, null, null); >+ >+ assertEquals(7, bug.getId()); >+ assertEquals("summary", bug.getSummary()); >+ assertEquals("7", bug.getAttribute("Bug#").getValue()); >+ assertEquals("7", bug.getAttribute("id").getValue()); >+ } >+ >+ public void testId2201() throws Exception { >+ >+ File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( >+ "testdata/pages/test-report-2201.html")); >+ Reader in = new FileReader(f); >+ >+ BugReport bug = BugParser.parseBug(in, 125527, TEST_SERVER, false, null, null, null); >+ >+ assertEquals(125527, bug.getId()); >+ assertEquals("bugzilla refresh incorrect for new reports and newly opened hits", bug.getSummary()); >+ assertEquals("125527", bug.getAttribute("Bug#").getValue()); >+ assertEquals("125527", bug.getAttribute("id").getValue()); >+ } >+ >+ public void testNewBugProduct220() throws Exception { >+ >+ NewBugzillaReport nbm = new NewBugzillaReport(); >+ >+ File f = FileTool >+ .getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/enter-bug220.html")); >+ Reader in = new FileReader(f); >+ >+ new NewBugParser(in).parseBugAttributes(nbm, true); >+ assertEquals(PRODUCT_TEST, nbm.getAttribute("product").getValue()); >+ } >+ >+ public void testNewBugProduct2201() throws Exception { >+ >+ NewBugzillaReport nbm = new NewBugzillaReport(); >+ >+ File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), >+ new Path("testdata/pages/enter-bug2201.html")); >+ Reader in = new FileReader(f); >+ >+ new NewBugParser(in).parseBugAttributes(nbm, true); >+ assertEquals(PRODUCT_MYLAR, nbm.getAttribute("product").getValue()); >+ } >+ >+} >Index: developer/scratch/bugzilla/BugzillaStackTraceTest.java >=================================================================== >RCS file: developer/scratch/bugzilla/BugzillaStackTraceTest.java >diff -N developer/scratch/bugzilla/BugzillaStackTraceTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ developer/scratch/bugzilla/BugzillaStackTraceTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,196 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+////Created on Oct 12, 2004 >+package org.eclipse.mylar.tests.misc; >+ >+import java.io.File; >+import java.io.FileReader; >+import java.io.Reader; >+import java.util.ArrayList; >+import java.util.List; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.core.runtime.Path; >+import org.eclipse.mylar.bugzilla.tests.BugzillaTestPlugin; >+import org.eclipse.mylar.core.tests.support.FileTool; >+import org.eclipse.mylar.internal.bugs.search.BugzillaMylarSearchOperation; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser; >+import org.eclipse.mylar.internal.bugzilla.core.search.BugzillaSearchHit; >+import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaReportNode; >+import org.eclipse.mylar.internal.bugzilla.ui.tasklist.StackTrace; >+ >+/** >+ * Class to test the Bridge methods that do not require server queries >+ * >+ * @author Shawn Minto >+ */ >+public class BugzillaStackTraceTest extends TestCase { >+ >+ private static final String TEST_FILE_LOC = "testdata/reports-stacktrace/"; >+ >+ private static final String BUGZILLA_SERVER_NAME = "https://bugs.eclipse.org/bugs"; >+ >+ /** >+ * Test that the regular expression escaping mechanism works properly >+ */ >+ public void testREGEX() { >+ String r = ".*+(){}[]^$|?/\\"; >+ String r2 = StackTrace.escapeForRegex(r); >+ String ans = "\\.\\*\\+\\(\\)\\{\\}\\[\\]\\^\\$\\|\\?\\/\\\\"; >+ String msg = "Regular Expression matching wrong:\nwas: " + r2 + "\nshould be:" + ans; >+ assertTrue(msg, r2.equals(ans)); >+ } >+ >+ // /** >+ // * Test parsing the bug for multiple stacks in in >+ // */ >+ // public void testMultipleStacksDiffComments(){ >+ // // REPORT_REPOSITORY 4862 - 2 stack traces - 1 in description, 1 in >+ // comment - text >+ // before and after >+ // performParse(4862, "4862.html", 2, false); >+ // } >+ >+ // /** >+ // * Test parsing the bug for a single stack in the description with some >+ // * text before it >+ // */ >+ // public void testSingleStackCodeBeforeInDescription(){ >+ // // REPORT_REPOSITORY 76388 - 1 stack trace - description - text before >+ // and formatted >+ // ugly >+ // performParse(76388, "76388.html", 1, false); >+ // } >+ >+ /** >+ * Test parsing the bug for a single stack trace in the description with >+ * text before and after it >+ */ >+ public void testSingleStackCodeBeforeAndAfterInDescription() { >+ >+ // REPORT_REPOSITORY 76146 - 1 stack trace - description - text before >+ // and code after >+ performParse(76146, "76146.html", 1, false); >+ } >+ >+ /** >+ * Test parsing a bug that has 1 stack trace in the description with no >+ * extra text, but has lines in it that span 3 lines >+ */ >+ public void testSingleStackPoorFormatInDescription() { >+ // REPORT_REPOSITORY 67395 - 1 stack trace - description - no extra >+ // text, 1 at line >+ // spans 3 lines >+ performParse(67395, "67395.html", 1, false); >+ } >+ >+ /** >+ * Test parsing a bug with no stack traces and no qualified exception names >+ */ >+ public void testNoStackNoQualified() { >+ // REPORT_REPOSITORY 4548 - no stack traces, no qualified reference to >+ // an exception >+ performParse(4548, "4548.html", 0, false); >+ } >+ >+ /** >+ * Test parsing a bug with no stack traces, but a qualified reference to an >+ * exception >+ */ >+ public void testNoStackQual() { >+ // REPORT_REPOSITORY 1 - no stack traces, qualified reference to >+ // exception - made up >+ // bug >+ performParse(1, "1.html", 0, false); >+ } >+ >+ /** >+ * Test parsing of a bug with 1 stack trace and multiple qualified >+ * references >+ */ >+ public void testSingleStackQual() { >+ // REPORT_REPOSITORY 2 - 1 stack trace- 2 qual ref, stack trace, 1 qual >+ // ref - made up >+ // bug >+ performParse(2, "2.html", 1, false); >+ } >+ >+ /** >+ * Test parsing of a bug with many stacks traces in a single comment >+ */ >+ public void testMultipleStackSingleComment() { >+ // REPORT_REPOSITORY 40152 - 1 stack trace- 2 qual ref, stack trace, 1 >+ // qual ref - made >+ // up bug >+ performParse(40152, "40152.html", 33, false); >+ } >+ >+ /** >+ * Print out the stack traces >+ * >+ * @param l >+ * List of stack traces >+ */ >+ private void printStackTraces(List<StackTrace> l) { >+ System.out.println("\n\n"); >+ for (int i = 0; i < l.size(); i++) { >+ StackTrace trace = l.get(i); >+ System.out.println("*****************?????????????????*****************\n"); >+ System.out.println("OFFSET: " + trace.getOffset() + " LENGTH: " + trace.getLength()); >+ System.out.println(trace.getStackTrace()); >+ System.out.println("*****************?????????????????*****************\n\n"); >+ } >+ } >+ >+ private void performParse(int bugNumber, String bugFileName, int numTracesExpected, boolean printStackTraces) { >+ >+ BugzillaSearchHit hit = new BugzillaSearchHit("<TEST-SERVER>", bugNumber, "", "", "", "", "", "", "", ""); // stack >+ // trace >+ // in >+ // desc >+ // and >+ // com >+ >+ // create a new doi info >+ BugzillaReportNode doi = new BugzillaReportNode(0, hit, false); >+ try { >+ >+ // read the bug in from a file >+ File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path(TEST_FILE_LOC + bugFileName)); // used >+ // if >+ // run >+ // as a >+ // plugin >+ // test >+ // File f = new File(TEST_FILE_LOC+bugFileName); // used if run as a >+ // standalone test >+ Reader reader = new FileReader(f); >+ doi.setBug(BugParser.parseBug(reader, hit.getId(), BUGZILLA_SERVER_NAME, true, null, null, null)); >+ reader.close(); >+ } catch (Exception e) { >+ e.printStackTrace(); >+ } >+ >+ // do a second pass parse on the bug >+ List<BugzillaReportNode> l = new ArrayList<BugzillaReportNode>(); >+ l.add(doi); >+ BugzillaMylarSearchOperation.secondPassBugzillaParser(l); >+ >+ // make sure that we received the right number of stack traces back >+ // System.out.println("*** REPORT_REPOSITORY " + hit.getId() + " ***"); >+ // System.out.println("NumStackTraces = " + >+ // doi.getStackTraces().size()); >+ assertEquals("Wrong Number stack traces", numTracesExpected, doi.getStackTraces().size()); >+ if (printStackTraces) >+ printStackTraces(doi.getStackTraces()); >+ } >+} >Index: developer/scratch/bugzilla/BugzillaNewBugParserTestCDT.java >=================================================================== >RCS file: developer/scratch/bugzilla/BugzillaNewBugParserTestCDT.java >diff -N developer/scratch/bugzilla/BugzillaNewBugParserTestCDT.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ developer/scratch/bugzilla/BugzillaNewBugParserTestCDT.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,213 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.tests; >+ >+import java.io.File; >+import java.io.FileReader; >+import java.io.Reader; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.core.runtime.Path; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.core.tests.support.FileTool; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; >+import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; >+ >+/** >+ * Tests NewBugParser -- parses product attributes for new bug reports >+ */ >+public class BugzillaNewBugParserTestCDT extends TestCase { >+ >+ public BugzillaNewBugParserTestCDT() { >+ super(); >+ } >+ >+ public BugzillaNewBugParserTestCDT(String arg0) { >+ super(arg0); >+ } >+ >+ public void testProductCDT() throws Exception { >+ >+ File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/cdt-page.html")); >+ >+ Reader in = new FileReader(f); >+ >+ NewBugzillaReport nbm = new NewBugzillaReport(); >+ new NewBugParser(in).parseBugAttributes(nbm, true); // ** TRUE vs FALSE >+ // ** >+ >+ // attributes for this bug model >+ List<AbstractRepositoryReportAttribute> attributes = nbm.getAttributes(); >+ // printList(attributes); >+ >+ Iterator<AbstractRepositoryReportAttribute> itr = attributes.iterator(); >+ AbstractRepositoryReportAttribute att = itr.next(); >+ >+ // Attribute: Severity >+ assertEquals("Attribute: Severity", "Severity", att.getName()); >+ >+ Map<String, String> attOptions = att.getOptionValues(); // HashMap of >+ // options for the >+ // current >+ // attribute >+ Object[] options = attOptions.keySet().toArray(); // Array of keys for >+ // the options of the >+ // current attribute >+ assertEquals("# Severity options", 7, options.length); >+ >+ int i = 0; >+ while (i < options.length) { >+ assertEquals("severity options", "blocker", options[i++]); >+ assertEquals("severity options", "critical", options[i++]); >+ assertEquals("severity options", "major", options[i++]); >+ assertEquals("severity options", "normal", options[i++]); >+ assertEquals("severity options", "minor", options[i++]); >+ assertEquals("severity options", "trivial", options[i++]); >+ assertEquals("severity options", "enhancement", options[i++]); >+ } >+ >+ // Attribute: product >+ att = itr.next(); >+ assertEquals("Attribute: product", "product", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("No product options", 0, options.length); >+ >+ // Attribute: AssignedTo >+ att = itr.next(); >+ assertEquals("Attribute: AssignedTo", "AssignedTo", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("No AssignedTo options", 0, options.length); >+ >+ // Attribute: OS >+ att = itr.next(); >+ assertEquals("Attribute: OS", "OS", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("# of options", 20, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("OS options", "All", options[i++]); >+ assertEquals("OS options", "AIX Motif", options[i++]); >+ assertEquals("OS options", "Windows 95", options[i++]); >+ assertEquals("OS options", "Windows 98", options[i++]); >+ assertEquals("OS options", "Windows CE", options[i++]); >+ assertEquals("OS options", "Windows ME", options[i++]); >+ assertEquals("OS options", "Windows 2000", options[i++]); >+ assertEquals("OS options", "Windows NT", options[i++]); >+ assertEquals("OS options", "Windows XP", options[i++]); >+ assertEquals("OS options", "Windows All", options[i++]); >+ assertEquals("OS options", "MacOS X", options[i++]); >+ assertEquals("OS options", "Linux", options[i++]); >+ assertEquals("OS options", "Linux-GTK", options[i++]); >+ assertEquals("OS options", "Linux-Motif", options[i++]); >+ assertEquals("OS options", "HP-UX", options[i++]); >+ assertEquals("OS options", "Neutrino", options[i++]); >+ assertEquals("OS options", "QNX-Photon", options[i++]); >+ assertEquals("OS options", "Solaris", options[i++]); >+ assertEquals("OS options", "Unix All", options[i++]); >+ assertEquals("OS options", "other", options[i++]); >+ } >+ >+ // Attribute: Version >+ att = itr.next(); >+ assertEquals("Attribute: Version", "Version", att.getName()); >+ >+ // attOptions = (HashMap) att.getOptionValues(); >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# Version options", 5, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Version options", "1.0", options[i++]); >+ assertEquals("Version options", "1.0.1", options[i++]); >+ assertEquals("Version options", "1.1", options[i++]); >+ assertEquals("Version options", "1.2", options[i++]); >+ assertEquals("Version options", "2.0", options[i++]); >+ } >+ >+ // Attribute: Platform >+ att = itr.next(); >+ assertEquals("Attribute: Platform", "Platform", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# Platform options", 6, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Platform options", "All", options[i++]); >+ assertEquals("Platform options", "Macintosh", options[i++]); >+ assertEquals("Platform options", "PC", options[i++]); >+ assertEquals("Platform options", "Power PC", options[i++]); >+ assertEquals("Platform options", "Sun", options[i++]); >+ assertEquals("Platform options", "Other", options[i++]); >+ } >+ >+ // Attribute: Component >+ att = itr.next(); >+ assertEquals("Attribute: Component", "Component", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# Component options", 9, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Component options", "CDT-parser", options[i++]); >+ assertEquals("Component options", "Core", options[i++]); >+ assertEquals("Component options", "Cpp-Extensions", options[i++]); >+ assertEquals("Component options", "Debug", options[i++]); >+ assertEquals("Component options", "Debug-MI", options[i++]); >+ assertEquals("Component options", "Doc", options[i++]); >+ assertEquals("Component options", "Generic-Extensions", options[i++]); >+ assertEquals("Component options", "Launcher", options[i++]); >+ assertEquals("Component options", "UI", options[i++]); >+ } >+ >+ // Attribute: bug_status >+ att = itr.next(); >+ assertEquals("Attribute: bug_status", "bug_status", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# bug_status options [none]", 0, options.length); >+ >+ // Attribute: form_name >+ att = itr.next(); >+ assertEquals("Attribute: form_name", "form_name", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No form_name options", 0, options.length); >+ >+ // Attribute: bug_file_loc >+ att = itr.next(); >+ assertEquals("Attribute: bug_file_loc", "bug_file_loc", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No bug_file_loc options", 0, options.length); >+ >+ // Attribute: priority >+ att = itr.next(); >+ assertEquals("Attribute: priority", "priority", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No priority options", 0, options.length); >+ >+ } >+} >Index: developer/scratch/bugzilla/NewBugParser.java >=================================================================== >RCS file: developer/scratch/bugzilla/NewBugParser.java >diff -N developer/scratch/bugzilla/NewBugParser.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ developer/scratch/bugzilla/NewBugParser.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,427 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.bugzilla.core.internal; >+ >+import java.io.IOException; >+import java.io.Reader; >+import java.text.ParseException; >+ >+import javax.security.auth.login.LoginException; >+ >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; >+import org.eclipse.mylar.internal.bugzilla.core.internal.HtmlStreamTokenizer.Token; >+ >+/** >+ * @author Shawn Minto >+ * >+ * This class parses the valid attribute values for a new bug >+ */ >+class NewBugParser { >+ /** Tokenizer used on the stream */ >+ private HtmlStreamTokenizer tokenizer; >+ >+ /** Flag for whether we need to try to get the product or not */ >+ private static boolean getProd = false; >+ >+ public NewBugParser(Reader in) { >+ tokenizer = new HtmlStreamTokenizer(in, null); >+ } >+ >+ /** >+ * Parse the new bugs valid attributes >+ * >+ * @param nbm >+ * A reference to a NewBugModel where all of the information is >+ * stored >+ * @throws IOException >+ * @throws ParseException >+ * @throws LoginException >+ */ >+ public void parseBugAttributes(NewBugzillaReport nbm, boolean retrieveProducts) throws IOException, ParseException, >+ LoginException { >+ nbm.attributes.clear(); // clear any attriubtes in bug model from a >+ // previous product >+ >+ NewBugParser.getProd = retrieveProducts; >+ >+ // create a new bug report and set the parser state to the start state >+ ParserState state = ParserState.START; >+ String attribute = null; >+ >+ boolean isTitle = false; >+ boolean possibleBadLogin = false; >+ boolean isErrorState = false; >+ String title = ""; >+ // Default error message >+ String errorMsg = "Bugzilla could not get the needed bug attribute since your login name or password is incorrect. Please check your settings in the bugzilla preferences."; >+ >+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >+ // make sure that bugzilla doesn't want us to login >+ if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.TITLE >+ && !((HtmlTag) (token.getValue())).isEndTag()) { >+ isTitle = true; >+ continue; >+ } >+ >+ if (isTitle) { >+ // get all of the data in the title tag to compare with >+ if (token.getType() != Token.TAG) { >+ title += ((StringBuffer) token.getValue()).toString().toLowerCase() + " "; >+ continue; >+ } else if (token.getType() == Token.TAG >+ && ((HtmlTag) token.getValue()).getTagType() == HtmlTag.Type.TITLE >+ && ((HtmlTag) token.getValue()).isEndTag()) { >+ // check if the title looks like we may have a problem with >+ // login >+ if (title.indexOf("login") != -1) { >+ possibleBadLogin = true; // generic / default msg >+ // passed to constructor re: >+ // bad login >+ } >+ if ((title.indexOf("invalid") != -1 && title.indexOf("password") != -1) >+ || title.indexOf("check e-mail") != -1 || title.indexOf("error") != -1) { >+ possibleBadLogin = true; >+ isErrorState = true; // set flag so appropriate msg >+ // is provide for the exception >+ errorMsg = ""; // error message will be parsed from >+ // error page >+ } >+ >+ isTitle = false; >+ title = ""; >+ } >+ continue; >+ } >+ >+ // we have found the start of an attribute name >+ if ((state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.TD && "right".equalsIgnoreCase(tag.getAttribute("align"))) { >+ // parse the attribute's name >+ attribute = parseAttributeName(); >+ if(attribute != null && attribute.contains(IBugzillaConstants.INVALID_2201_ATTRIBUTE_IGNORED)) { >+ continue; >+ } >+ if (attribute == null) >+ continue; >+ state = ParserState.ATT_VALUE; >+ continue; >+ } >+ >+ if (tag.getTagType() == HtmlTag.Type.TD && "#ff0000".equalsIgnoreCase(tag.getAttribute("bgcolor"))) { >+ state = ParserState.ERROR; >+ continue; >+ } >+ } >+ >+ // we have found the start of attribute values >+ if (state == ParserState.ATT_VALUE && token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.TD) { >+ // parse the attribute values >+ parseAttributeValue(nbm, attribute); >+ >+ state = ParserState.ATT_NAME; >+ attribute = null; >+ continue; >+ } >+ } >+ // page being parsed contains an Error message >+ // parse error message so it can be given to the constructor of the >+ // exception >+ // so an appropriate error message is displayed >+ if (state == ParserState.ERROR && isErrorState) { >+ // tag should be text token, not a tag >+ // get the error message >+ if (token.getType() == Token.TEXT) { >+ // get string value of next token to add to error messgage >+ // unescape the string so any escape sequences parsed appear >+ // unescaped in the details pane >+ errorMsg += HtmlStreamTokenizer.unescape(((StringBuffer) token.getValue()).toString()) + " "; >+ } >+ // expect </font> tag to indicate end of error end msg >+ // set next state to continue parsing remainder of page >+ else if (token.getType() == Token.TAG >+ && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.FONT >+ && ((HtmlTag) (token.getValue())).isEndTag()) { >+ state = ParserState.ATT_NAME; >+ } >+ continue; >+ } >+ >+ if ((state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.INPUT && tag.getAttribute("type") != null >+ && "hidden".equalsIgnoreCase(tag.getAttribute("type").trim())) { >+ AbstractRepositoryReportAttribute a = new AbstractRepositoryReportAttribute(tag.getAttribute("name")); >+ a.setID(tag.getAttribute("name")); >+ a.setValue(tag.getAttribute("value")); >+ a.setHidden(true); >+ nbm.attributes.put(a.getName(), a); >+ continue; >+ } >+ } >+ } >+ >+ if (possibleBadLogin && (nbm.getAttributes() == null || nbm.getAttributes().size() == 0)) { >+ throw new LoginException(errorMsg); >+ } >+ } >+ >+ /** >+ * Parse the case where we have found an attribute name >+ * >+ * @param tokenizer >+ * The tokenizer to use to find the name >+ * @return The name of the attribute >+ * @throws IOException >+ * @throws ParseException >+ */ >+ private String parseAttributeName() throws IOException, ParseException { >+ StringBuffer sb = new StringBuffer(); >+ >+ parseTableCell(sb); >+ HtmlStreamTokenizer.unescape(sb); >+ // remove the colon if there is one >+ if (sb.length() == 0) >+ return null; >+ if (sb.charAt(sb.length() - 1) == ':') { >+ sb.deleteCharAt(sb.length() - 1); >+ } >+ return sb.toString(); >+ } >+ >+ /** >+ * Reads text into a StringBuffer until it encounters a close table cell tag >+ * (</TD>) or start of another cell. The text is appended to the >+ * existing value of the buffer. <b>NOTE:</b> Does not handle nested cells! >+ * >+ * @param tokenizer >+ * @param sb >+ * @throws IOException >+ * @throws ParseException >+ */ >+ private void parseTableCell(StringBuffer sb) throws IOException, ParseException { >+ boolean noWhitespace = false; >+ for (HtmlStreamTokenizer.Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer >+ .nextToken()) { >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.TD) { >+ if (!tag.isEndTag()) { >+ tokenizer.pushback(token); >+ } >+ break; >+ } >+ noWhitespace = token.getWhitespace().length() == 0; >+ } else if (token.getType() == Token.TEXT) { >+ // if there was no whitespace between the tag and the >+ // preceding text, don't insert whitespace before this text >+ // unless it is there in the source >+ if (!noWhitespace && token.getWhitespace().length() > 0 && sb.length() > 0) { >+ sb.append(' '); >+ } >+ sb.append((StringBuffer) token.getValue()); >+ } >+ } >+ } >+ >+ /** >+ * Parse the case where we have found attribute values >+ * >+ * @param nbm >+ * The NewBugModel that is to contain information about a new bug >+ * @param attributeName >+ * The name of the attribute that we are parsing >+ * @param tokenizer >+ * The tokenizer to use for parsing >+ * @throws IOException >+ * @throws ParseException >+ */ >+ private void parseAttributeValue(NewBugzillaReport nbm, String attributeName) throws IOException, ParseException { >+ >+ HtmlStreamTokenizer.Token token = tokenizer.nextToken(); >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.SELECT && !tag.isEndTag()) { >+ String parameterName = tag.getAttribute("name"); >+ parseSelect(nbm, attributeName, parameterName); >+ } else if (tag.getTagType() == HtmlTag.Type.INPUT && !tag.isEndTag()) { >+ parseInput(nbm, attributeName, tag); >+ } else if (!tag.isEndTag()) { >+ parseAttributeValueCell(nbm, attributeName); >+ } >+ } else { >+ StringBuffer sb = new StringBuffer(); >+ if (token.getType() == Token.TEXT) { >+ sb.append((StringBuffer) token.getValue()); >+ parseAttributeValueCell(nbm, attributeName, sb); >+ } >+ } >+ } >+ >+ /** >+ * Parse the case where the attribute value is just text in a table cell >+ * >+ * @param attributeName >+ * The name of the attribute we are parsing >+ * @param tokenizer >+ * The tokenizer to use for parsing >+ * @throws IOException >+ * @throws ParseException >+ */ >+ private void parseAttributeValueCell(NewBugzillaReport nbm, String attributeName) throws IOException, ParseException { >+ StringBuffer sb = new StringBuffer(); >+ >+ parseAttributeValueCell(nbm, attributeName, sb); >+ } >+ >+ private void parseAttributeValueCell(NewBugzillaReport nbm, String attributeName, StringBuffer sb) throws IOException, >+ ParseException { >+ >+ parseTableCell(sb); >+ HtmlStreamTokenizer.unescape(sb); >+ >+ // if we need the product we will get it >+ if (getProd && attributeName.equalsIgnoreCase("product")) { >+ nbm.setProduct(sb.toString()); >+ } >+ } >+ >+ /** >+ * Parse the case where the attribute value is an input >+ * >+ * @param nbm >+ * The new bug model to add information that we get to >+ * @param attributeName >+ * The name of the attribute that we are parsing >+ * @param tag >+ * The HTML tag that we are currently on >+ * @throws IOException >+ */ >+ private static void parseInput(NewBugzillaReport nbm, String attributeName, HtmlTag tag) throws IOException { >+ >+ AbstractRepositoryReportAttribute a = new AbstractRepositoryReportAttribute(attributeName); >+ a.setID(tag.getAttribute("name")); >+ String value = tag.getAttribute("value"); >+ if (value == null) >+ value = ""; >+ >+ // if we found the summary, add it to the bug report >+ if (attributeName.equalsIgnoreCase("summary")) { >+ nbm.setSummary(value); >+ } else if (attributeName.equalsIgnoreCase("Attachments")) { >+ // do nothing - not a problem after 2.14 >+ } else if (attributeName.equalsIgnoreCase("add cc")) { >+ // do nothing >+ } else if (attributeName.toLowerCase().startsWith("cc")) { >+ // do nothing cc's are options not inputs >+ } else { >+ // otherwise just add the attribute >+ a.setValue(value); >+ nbm.attributes.put(attributeName, a); >+ } >+ } >+ >+ /** >+ * Parse the case where the attribute value is an option >+ * >+ * @param nbm >+ * The NewBugModel that we are storing information in >+ * @param attributeName >+ * The name of the attribute that we are parsing >+ * @param parameterName >+ * The SELECT tag's name >+ * @param tokenizer >+ * The tokenizer that we are using for parsing >+ * @throws IOException >+ * @throws ParseException >+ */ >+ private void parseSelect(NewBugzillaReport nbm, String attributeName, String parameterName) throws IOException, >+ ParseException { >+ >+ boolean first = false; >+ AbstractRepositoryReportAttribute a = new AbstractRepositoryReportAttribute(attributeName); >+ a.setID(parameterName); >+ >+ HtmlStreamTokenizer.Token token = tokenizer.nextToken(); >+ while (token.getType() != Token.EOF) { >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.SELECT && tag.isEndTag()) >+ break; >+ if (tag.getTagType() == HtmlTag.Type.OPTION && !tag.isEndTag()) { >+ String optionName = tag.getAttribute("value"); >+ boolean selected = tag.hasAttribute("selected"); >+ StringBuffer optionText = new StringBuffer(); >+ for (token = tokenizer.nextToken(); token.getType() == Token.TEXT; token = tokenizer.nextToken()) { >+ if (optionText.length() > 0) { >+ optionText.append(' '); >+ } >+ optionText.append((StringBuffer) token.getValue()); >+ } >+ a.addOptionValue(optionText.toString(), optionName); >+ >+ if (selected || first) { >+ a.setValue(optionText.toString()); >+ first = false; >+ } >+ } else { >+ token = tokenizer.nextToken(); >+ } >+ } else { >+ token = tokenizer.nextToken(); >+ } >+ } >+ >+ if (!(nbm.attributes).containsKey(attributeName)) { >+ (nbm.attributes).put(attributeName, a); >+ } >+ } >+ >+ /** >+ * Enum class for describing current state of Bugzilla report parser. >+ */ >+ private static class ParserState { >+ /** An instance of the start state */ >+ protected static final ParserState START = new ParserState("start"); >+ >+ /** An instance of the state when the parser found an attribute name */ >+ protected static final ParserState ATT_NAME = new ParserState("att_name"); >+ >+ /** An instance of the state when the parser found an attribute value */ >+ protected static final ParserState ATT_VALUE = new ParserState("att_value"); >+ >+ /** An instance of the state when an error page is found */ >+ protected static final ParserState ERROR = new ParserState("error"); >+ >+ /** State's human-readable name */ >+ private String name; >+ >+ /** >+ * Constructor >+ * >+ * @param description - >+ * The states human readable name >+ */ >+ private ParserState(String description) { >+ this.name = description; >+ } >+ >+ @Override >+ public String toString() { >+ return name; >+ } >+ } >+} >Index: developer/scratch/bugzilla/BugzillaNewBugParserTestGMT.java >=================================================================== >RCS file: developer/scratch/bugzilla/BugzillaNewBugParserTestGMT.java >diff -N developer/scratch/bugzilla/BugzillaNewBugParserTestGMT.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ developer/scratch/bugzilla/BugzillaNewBugParserTestGMT.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,219 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.tests; >+ >+import java.io.File; >+import java.io.FileReader; >+import java.io.Reader; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.core.runtime.Path; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.core.tests.support.FileTool; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; >+import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; >+ >+/** >+ * Tests NewBugParser -- parses product attributes >+ */ >+public class BugzillaNewBugParserTestGMT extends TestCase { >+ >+ public BugzillaNewBugParserTestGMT() { >+ super(); >+ } >+ >+ public BugzillaNewBugParserTestGMT(String arg0) { >+ super(arg0); >+ } >+ >+ public void testProductGMT() throws Exception { >+ >+ File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/gmt-page.html")); >+ >+ Reader in = new FileReader(f); >+ >+ NewBugzillaReport nbm = new NewBugzillaReport(); >+ new NewBugParser(in).parseBugAttributes(nbm, true); // ** TRUE vs FALSE >+ // ** >+ >+ // attributes for this bug model >+ List<AbstractRepositoryReportAttribute> attributes = nbm.getAttributes(); >+ // printList(attributes); >+ >+ Iterator<AbstractRepositoryReportAttribute> itr = attributes.iterator(); >+ AbstractRepositoryReportAttribute att = itr.next(); >+ >+ // Attribute: Severity >+ assertEquals("Attribute: Severity", "Severity", att.getName()); >+ >+ Map<String, String> attOptions = att.getOptionValues(); // HashMap of >+ // options for the >+ // current >+ // attribute >+ Object[] options = attOptions.keySet().toArray(); // Array of keys for >+ // the options of the >+ // current attribute >+ assertEquals("# Severity options", 7, options.length); >+ >+ int i = 0; >+ while (i < options.length) { >+ assertEquals("severity options", "blocker", options[i++]); >+ assertEquals("severity options", "critical", options[i++]); >+ assertEquals("severity options", "major", options[i++]); >+ assertEquals("severity options", "normal", options[i++]); >+ assertEquals("severity options", "minor", options[i++]); >+ assertEquals("severity options", "trivial", options[i++]); >+ assertEquals("severity options", "enhancement", options[i++]); >+ } >+ >+ // Attribute: product >+ att = itr.next(); >+ assertEquals("Attribute: product", "product", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("No product options", 0, options.length); >+ >+ // Attribute: AssignedTo >+ att = itr.next(); >+ assertEquals("Attribute: AssignedTo", "AssignedTo", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("No AssignedTo options", 0, options.length); >+ >+ // Attribute: OS >+ att = itr.next(); >+ assertEquals("Attribute: OS", "OS", att.getName()); >+ >+ attOptions = att.getOptionValues(); >+ options = attOptions.keySet().toArray(); >+ assertEquals("# of options", 20, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("OS options", "All", options[i++]); >+ assertEquals("OS options", "AIX Motif", options[i++]); >+ assertEquals("OS options", "Windows 95", options[i++]); >+ assertEquals("OS options", "Windows 98", options[i++]); >+ assertEquals("OS options", "Windows CE", options[i++]); >+ assertEquals("OS options", "Windows ME", options[i++]); >+ assertEquals("OS options", "Windows 2000", options[i++]); >+ assertEquals("OS options", "Windows NT", options[i++]); >+ assertEquals("OS options", "Windows XP", options[i++]); >+ assertEquals("OS options", "Windows All", options[i++]); >+ assertEquals("OS options", "MacOS X", options[i++]); >+ assertEquals("OS options", "Linux", options[i++]); >+ assertEquals("OS options", "Linux-GTK", options[i++]); >+ assertEquals("OS options", "Linux-Motif", options[i++]); >+ assertEquals("OS options", "HP-UX", options[i++]); >+ assertEquals("OS options", "Neutrino", options[i++]); >+ assertEquals("OS options", "QNX-Photon", options[i++]); >+ assertEquals("OS options", "Solaris", options[i++]); >+ assertEquals("OS options", "Unix All", options[i++]); >+ assertEquals("OS options", "other", options[i++]); >+ } >+ >+ // Attribute: Version >+ att = itr.next(); >+ assertEquals("Attribute: Version", "Version", att.getName()); >+ >+ // attOptions = (HashMap) att.getOptionValues(); >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# Version options", 1, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Version options", "unspecified", options[i++]); >+ } >+ >+ // Attribute: Platform >+ att = itr.next(); >+ assertEquals("Attribute: Platform", "Platform", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# Platform options", 6, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Platform options", "All", options[i++]); >+ assertEquals("Platform options", "Macintosh", options[i++]); >+ assertEquals("Platform options", "PC", options[i++]); >+ assertEquals("Platform options", "Power PC", options[i++]); >+ assertEquals("Platform options", "Sun", options[i++]); >+ assertEquals("Platform options", "Other", options[i++]); >+ } >+ >+ att = itr.next(); >+ assertEquals("Attribute: Component", "Component", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# Component options", 1, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Component options", "Core", options[i++]); >+ } >+ >+ // Attribute: bug_status >+ att = itr.next(); >+ assertEquals("Attribute: bug_status", "bug_status", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No bug_status options", 0, options.length); >+ >+ // Attribute: form_name >+ att = itr.next(); >+ assertEquals("Attribute: form_name", "form_name", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No form_name options", 0, options.length); >+ >+ // Attribute: bug_file_loc >+ att = itr.next(); >+ assertEquals("Attribute: bug_file_loc", "bug_file_loc", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No bug_file_loc options", 0, options.length); >+ >+ // Attribute: priority >+ att = itr.next(); >+ assertEquals("Attribute: priority", "priority", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No priority options", 0, options.length); >+ >+ } >+ >+ // private void printList(List<Attribute> attributes) { >+ // >+ // Iterator<Attribute> itr = attributes.iterator(); >+ // System.out.println("Attributes for this Product:"); >+ // System.out.println("============================"); >+ // >+ // while (itr.hasNext()) { >+ // Attribute attr = itr.next(); >+ // System.out.println(); >+ // System.out.println(attr.getName() + ": "); >+ // System.out.println("-----------"); >+ // >+ // Map<String, String> options = attr.getOptionValues(); >+ // Object[] it = options.keySet().toArray(); >+ // for (int i = 0; i < it.length; i++) >+ // System.out.println((String) it[i]); >+ // } >+ // } >+} >Index: developer/scratch/bugzilla/BugParser.java >=================================================================== >RCS file: developer/scratch/bugzilla/BugParser.java >diff -N developer/scratch/bugzilla/BugParser.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ developer/scratch/bugzilla/BugParser.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,1107 @@ >+/******************************************************************************* >+ * Copyright (c) 2003 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.mylar.internal.bugzilla.core.internal; >+ >+import java.io.BufferedReader; >+import java.io.IOException; >+import java.io.InputStreamReader; >+import java.io.Reader; >+import java.net.URL; >+import java.net.URLConnection; >+import java.net.URLEncoder; >+import java.nio.charset.Charset; >+import java.text.ParseException; >+import java.text.SimpleDateFormat; >+import java.util.Calendar; >+import java.util.Date; >+import java.util.Iterator; >+import java.util.List; >+ >+import javax.security.auth.login.LoginException; >+ >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.Comment; >+import org.eclipse.mylar.bugzilla.core.Operation; >+import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; >+import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >+import org.eclipse.mylar.internal.bugzilla.core.internal.HtmlStreamTokenizer.Token; >+ >+/** >+ * @author Shawn Minto >+ * @author Mik Kersten (hardening of prototype) >+ * @author Rob Elves (attachments) This class parses bugs so that they can be >+ * displayed using the bug editor >+ */ >+public class BugParser { >+ >+ private static final String VALUE_ATTACHMENT_OBSOLETE = "bz_obsolete"; >+ >+ private static final String ATTRIBUTE_CLASS = "class"; >+ >+ private static final String TAG_SPAN = "span"; >+ >+ private static final String ATTRIBUTE_ID_TITLE = "title"; >+ >+ private static final String ATTRIBUTE_ID_HREF = "href"; >+ >+ private static final String ATTACHMENT_CGI_ID = "attachment.cgi?id="; >+ >+ private static final String KEY_BUG_NUM = "Bug#"; >+ >+ private static final String KEY_RESOLUTION = "resolution"; >+ >+ private static final String KEY_VALUE = "value"; >+ >+ private static final String KEY_NAME = "name"; >+ >+ private static final String ATTR_CHARSET = "charset"; >+ >+ /** Parser for dates in the report */ >+ private static SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); >+ >+ private static final String keywordsUrl = "describekeywords.cgi"; >+ >+ /** >+ * Parse the case where we have found an attribute name >+ * >+ * @param in >+ * The input stream for the bug >+ * @return The name of the attribute that we are parsing >+ * @throws IOException >+ */ >+ private static String parseAttributeName(HtmlStreamTokenizer tokenizer) throws IOException, ParseException { >+ StringBuffer sb = new StringBuffer(); >+ >+ parseTableCell(tokenizer, sb); >+ HtmlStreamTokenizer.unescape(sb); >+ // remove the colon if there is one >+ if (sb.length() > 0 && sb.charAt(sb.length() - 1) == ':') { >+ sb.deleteCharAt(sb.length() - 1); >+ } >+ return sb.toString(); >+ } >+ >+ /** >+ * Parse the case where we have found attribute values >+ * >+ * @param in >+ * The input stream of the bug >+ * @param bug >+ * The bug report for the current bug >+ * @param attribute >+ * The name of the attribute >+ * @throws IOException >+ */ >+ private static void parseAttributeValue(BugReport bug, String originalAttributeName, HtmlStreamTokenizer tokenizer, >+ String serverUrl, String userName, String password) throws IOException, ParseException { >+ >+ // NOTE: special rule to deal with change in 2.20.1 >+ String attributeName = originalAttributeName; >+ if (attributeName.endsWith(KEY_BUG_NUM) && attributeName.length() > KEY_BUG_NUM.length()) { >+ attributeName = originalAttributeName.substring(attributeName.length() - KEY_BUG_NUM.length(), >+ attributeName.length()); >+ } >+ >+ Token token = tokenizer.nextToken(); >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ >+ // make sure that we are on a tag that we care about, not a label >+ // fix added so that we can parse the mozilla bug pages >+ if (tag.getTagType() == HtmlTag.Type.LABEL) { >+ token = tokenizer.nextToken(); >+ if (token.getType() == Token.TAG) >+ tag = (HtmlTag) token.getValue(); >+ else { >+ StringBuffer sb = new StringBuffer(); >+ if (token.getType() == Token.TEXT) { >+ sb.append((StringBuffer) token.getValue()); >+ parseAttributeValueCell(bug, attributeName, tokenizer, sb); >+ } >+ } >+ } >+ >+ if (tag.getTagType() == HtmlTag.Type.SELECT && !tag.isEndTag()) { >+ String parameterName = tag.getAttribute(KEY_NAME); >+ parseSelect(bug, attributeName, parameterName, tokenizer); >+ } else if (tag.getTagType() == HtmlTag.Type.INPUT && !tag.isEndTag()) { >+ parseInput(bug, attributeName, tag, serverUrl, userName, password); >+ } else if (!tag.isEndTag() || attributeName.equalsIgnoreCase(KEY_RESOLUTION)) { >+ if (tag.isEndTag() && attributeName.equalsIgnoreCase(KEY_RESOLUTION)) { >+ AbstractRepositoryReportAttribute a = new AbstractRepositoryReportAttribute(attributeName); >+ a.setValue(""); >+ bug.addAttribute(a); >+ } >+ parseAttributeValueCell(bug, attributeName, tokenizer); >+ } >+ } else { >+ StringBuffer sb = new StringBuffer(); >+ if (token.getType() == Token.TEXT) { >+ sb.append((StringBuffer) token.getValue()); >+ parseAttributeValueCell(bug, attributeName, tokenizer, sb); >+ } >+ } >+ } >+ >+ /** >+ * Parse the case where the attribute value is just text in a table cell >+ * >+ * @param in >+ * The input stream of the bug >+ * @param bug >+ * The bug report for the current bug >+ * @param attributeName >+ * The name of the attribute that we are parsing >+ * @throws IOException >+ */ >+ private static void parseAttributeValueCell(BugReport bug, String attributeName, HtmlStreamTokenizer tokenizer) >+ throws IOException, ParseException { >+ StringBuffer sb = new StringBuffer(); >+ parseAttributeValueCell(bug, attributeName, tokenizer, sb); >+ } >+ >+ private static void parseAttributeValueCell(BugReport bug, String attributeName, HtmlStreamTokenizer tokenizer, >+ StringBuffer sb) throws IOException, ParseException { >+ >+ parseTableCell(tokenizer, sb); >+ HtmlStreamTokenizer.unescape(sb); >+ >+ // create a new attribute and set its value to the value that we >+ // retrieved >+ AbstractRepositoryReportAttribute a = new AbstractRepositoryReportAttribute(attributeName); >+ a.setValue(sb.toString()); >+ >+ // if we found an attachment attribute, forget about it, else add the >+ // attribute to the bug report >+ if (attributeName.toLowerCase().startsWith("attachments")) { >+ // do nothing >+ } else { >+ if (attributeName.equals(KEY_BUG_NUM)) >+ a.setValue(a.getValue().replaceFirst("alias:", "")); >+ bug.addAttribute(a); >+ } >+ } >+ >+ /** >+ * Reads text into a StringBuffer until it encounters a close table cell tag >+ * (</TD>) or start of another cell. The text is appended to the >+ * existing value of the buffer. <b>NOTE:</b> Does not handle nested cells! >+ * >+ * @param tokenizer >+ * @param sb >+ * @throws IOException >+ * @throws ParseException >+ */ >+ private static void parseTableCell(HtmlStreamTokenizer tokenizer, StringBuffer sb) throws IOException, >+ ParseException { >+ boolean noWhitespace = false; >+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.TD) { >+ if (!tag.isEndTag()) { >+ tokenizer.pushback(token); >+ } >+ break; >+ } >+ noWhitespace = token.getWhitespace().length() == 0; >+ } else if (token.getType() == Token.TEXT) { >+ // if there was no whitespace between the tag and the >+ // preceding text, don't insert whitespace before this text >+ // unless it is there in the source >+ if (!noWhitespace && token.getWhitespace().length() > 0 && sb.length() > 0) { >+ sb.append(' '); >+ } >+ sb.append((StringBuffer) token.getValue()); >+ } >+ } >+ } >+ >+ /** >+ * Parse the case where the attribute value is an option >+ * >+ * @param in >+ * The input stream for the bug >+ * @param bug >+ * The bug report for the current bug >+ * @param attribute >+ * The name of the attribute that we are parsing >+ * @param parameterName >+ * the SELECT tag's name >+ * @throws IOException >+ */ >+ private static void parseSelect(BugReport bug, String attributeName, String parameterName, >+ HtmlStreamTokenizer tokenizer) throws IOException, ParseException { >+ >+ boolean first = false; >+ AbstractRepositoryReportAttribute a = new AbstractRepositoryReportAttribute(attributeName); >+ a.setID(parameterName); >+ >+ Token token = tokenizer.nextToken(); >+ while (token.getType() != Token.EOF) { >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.SELECT && tag.isEndTag()) >+ break; >+ if (tag.getTagType() == HtmlTag.Type.OPTION && !tag.isEndTag()) { >+ String optionName = tag.getAttribute(KEY_VALUE); >+ boolean selected = tag.hasAttribute("selected"); >+ StringBuffer optionText = new StringBuffer(); >+ for (token = tokenizer.nextToken(); token.getType() == Token.TEXT; token = tokenizer.nextToken()) { >+ if (optionText.length() > 0) { >+ optionText.append(' '); >+ } >+ optionText.append((StringBuffer) token.getValue()); >+ } >+ a.addOptionValue(optionText.toString(), optionName); >+ if (selected || first) { >+ a.setValue(optionText.toString()); >+ first = false; >+ } >+ } else { >+ token = tokenizer.nextToken(); >+ } >+ } else { >+ token = tokenizer.nextToken(); >+ } >+ } >+ >+ // if we parsed the cc field add the e-mails to the bug report else add >+ // the attribute to the bug report >+ if (attributeName.toLowerCase().startsWith("cc")) { >+ for (Iterator<String> it = a.getOptionValues().keySet().iterator(); it.hasNext();) { >+ String email = it.next(); >+ bug.addCC(HtmlStreamTokenizer.unescape(email)); >+ } >+ } else { >+ bug.addAttribute(a); >+ } >+ } >+ >+ /** >+ * Parse the case where the attribute value is an input >+ * >+ * @param bug >+ * The bug report for the current bug >+ * @param attributeName >+ * The name of the attribute >+ * @param tag >+ * The INPUT tag >+ * @throws IOException >+ */ >+ private static void parseInput(BugReport bug, String attributeName, HtmlTag tag, String serverUrl, String userName, >+ String password) throws IOException { >+ >+ AbstractRepositoryReportAttribute a = new AbstractRepositoryReportAttribute(attributeName); >+ a.setID(tag.getAttribute(KEY_NAME)); >+ String name = tag.getAttribute(KEY_NAME); >+ String value = tag.getAttribute(KEY_VALUE); >+ if (value == null) >+ value = ""; >+ >+ // if we found the summary, add it to the bug report >+ if (name.equalsIgnoreCase("short_desc")) { >+ bug.setSummary(value); >+ } else if (name.equalsIgnoreCase("bug_file_loc")) { >+ a.setValue(value); >+ bug.addAttribute(a); >+ } else if (name.equalsIgnoreCase("newcc")) { >+ a.setValue(value); >+ bug.addAttribute(a); >+ } else { >+ // otherwise just add the attribute >+ a.setValue(value); >+ bug.addAttribute(a); >+ >+ if (attributeName.equalsIgnoreCase("keywords") && serverUrl != null) { >+ >+ BufferedReader input = null; >+ try { >+ >+ String urlText = ""; >+ >+ // if we have a user name, may as well log in just in case >+ // it is required >+ if (userName != null && !userName.equals("") && password != null && !password.equals("")) { >+ /* >+ * The UnsupportedEncodingException exception for >+ * URLEncoder.encode() should not be thrown, since every >+ * implementation of the Java platform is required to >+ * support the standard charset "UTF-8" >+ */ >+ urlText += "?GoAheadAndLogIn=1&Bugzilla_login=" + URLEncoder.encode(userName, "UTF-8") >+ + "&Bugzilla_password=" + URLEncoder.encode(password, "UTF-8"); >+ } >+ >+ // connect to the bugzilla server to get the keyword list >+ URL url = new URL(serverUrl + "/" + keywordsUrl + urlText); >+ URLConnection urlConnection = BugzillaPlugin.getDefault().getUrlConnection(url); >+ input = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); >+ >+ // parse the valid keywords and add them to the bug >+ List<String> keywords = new KeywordParser(input).getKeywords(); >+ bug.setKeywords(keywords); >+ >+ } catch (Exception e) { >+ // throw an exception if there is a problem reading the bug >+ // from the server >+ throw new IOException("Exception while fetching the list of keywords from the server: " >+ + e.getMessage()); >+ } finally { >+ try { >+ if (input != null) >+ input.close(); >+ } catch (IOException e) { >+ BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.ERROR, >+ "Problem closing the stream", e)); >+ } >+ } >+ } >+ } >+ } >+ >+ /** >+ * Parse the case where we are dealing with the description >+ * >+ * @param bug >+ * The bug report for the bug >+ * @throws IOException >+ */ >+ private static void parseDescription(BugReport bug, HtmlStreamTokenizer tokenizer) throws IOException, >+ ParseException { >+ >+ StringBuffer sb = new StringBuffer(); >+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (sb.length() > 0) { >+ sb.append(token.getWhitespace()); >+ } >+ if (tag.getTagType() == HtmlTag.Type.PRE && tag.isEndTag()) >+ break; >+ } else if (token.getType() == Token.TEXT) { >+ if (sb.length() > 0) { >+ sb.append(token.getWhitespace()); >+ } >+ sb.append((StringBuffer) token.getValue()); >+ } >+ } >+ >+ // set the bug to have the description we retrieved >+ String text = HtmlStreamTokenizer.unescape(sb).toString(); >+ bug.setDescription(text); >+ } >+ >+ // /** >+ // * parses the description of an attachment on the report >+ // */ >+ // private static String parseAttachementDescription(HtmlStreamTokenizer >+ // tokenizer) throws IOException, >+ // ParseException { >+ // >+ // StringBuffer sb = new StringBuffer(); >+ // for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; >+ // token = tokenizer.nextToken()) { >+ // if (token.getType() == Token.TAG) { >+ // HtmlTag tag = (HtmlTag) token.getValue(); >+ // if (tag.getTagType() == HtmlTag.Type.A && tag.isEndTag()) >+ // break; >+ // } else if (token.getType() == Token.TEXT) { >+ // if (sb.length() > 0) { >+ // sb.append(token.getWhitespace()); >+ // } >+ // sb.append((StringBuffer) token.getValue()); >+ // } >+ // } >+ // >+ // // set the bug to have the description we retrieved >+ // String text = HtmlStreamTokenizer.unescape(sb).toString(); >+ // return text; >+ // } >+ >+ /** >+ * Parse the case where we have found the start of a comment >+ * >+ * @param in >+ * The input stream of the bug >+ * @param bug >+ * The bug report for the current bug >+ * @return The comment that we have created with the information >+ * @throws IOException >+ * @throws ParseException >+ */ >+ private static Comment parseCommentHead(BugReport bug, HtmlStreamTokenizer tokenizer) throws IOException, >+ ParseException { >+ int number = 0; >+ Date date = null; >+ String author = null; >+ String authorName = null; >+ >+ // get the comment's number >+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.A) { >+ String href = tag.getAttribute(ATTRIBUTE_ID_HREF); >+ if (href != null) { >+ int index = href.toLowerCase().indexOf("#c"); >+ if (index == -1) >+ continue; >+ token = tokenizer.nextToken(); >+ number = Integer.parseInt(((StringBuffer) token.getValue()).toString().substring(1)); >+ break; >+ } >+ } >+ } >+ } >+ >+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.A) { >+ String href = tag.getAttribute(ATTRIBUTE_ID_HREF); >+ if (href != null) { >+ int index = href.toLowerCase().indexOf("mailto"); >+ if (index == -1) >+ continue; >+ author = href.substring(index + 7); >+ break; >+ } >+ } >+ } >+ } >+ >+ // get the author's real name >+ StringBuffer sb = new StringBuffer(); >+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.A && tag.isEndTag()) >+ break; >+ } else if (token.getType() == Token.TEXT) { >+ if (sb.length() > 0) { >+ sb.append(' '); >+ } >+ sb.append((StringBuffer) token.getValue()); >+ } >+ } >+ authorName = sb.toString(); >+ >+ // get the comment's date >+ sb.setLength(0); >+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.I && tag.isEndTag()) >+ break; >+ } else if (token.getType() == Token.TEXT) { >+ if (sb.length() > 0) { >+ sb.append(' '); >+ } >+ sb.append((StringBuffer) token.getValue()); >+ } >+ } >+ try { >+ if (sb.length() >= 16) { >+ date = df.parse(sb.substring(0, 16)); >+ } >+ } catch (Exception e) { >+ date = Calendar.getInstance().getTime(); // XXX: could not >+ // determine date >+ } >+ return new Comment(bug, number, date, author, authorName); >+ } >+ >+ /** >+ * Parse the case where we have comment text >+ * >+ * @param in >+ * The input stream for the bug >+ * @param bug >+ * The bug report for the current bug >+ * @param comment >+ * The comment to add the text to >+ * @throws IOException >+ */ >+ private static void parseCommentText(BugReport bug, Comment comment, HtmlStreamTokenizer tokenizer) >+ throws IOException, ParseException { >+ >+ StringBuffer commentStringBuffer = new StringBuffer(); >+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagName().equals(TAG_SPAN)) { >+ if(tag.hasAttribute(ATTRIBUTE_CLASS) && tag.getAttribute(ATTRIBUTE_CLASS).equals("")) { >+ parseAttachment(commentStringBuffer, comment, tokenizer, false); >+ continue; >+ } else if(tag.hasAttribute(ATTRIBUTE_CLASS) && tag.getAttribute(ATTRIBUTE_CLASS).equals(VALUE_ATTACHMENT_OBSOLETE)) { >+ parseAttachment(commentStringBuffer, comment, tokenizer, true); >+ continue; >+ } >+ } >+ // added to ensure whitespace is not >+ // lost if adding a tag within a tag >+ if (commentStringBuffer.length() > 0) { >+ commentStringBuffer.append(token.getWhitespace()); >+ } >+ if (tag.getTagType() == HtmlTag.Type.PRE && tag.isEndTag()) >+ break; >+ } else if (token.getType() == Token.TEXT) { >+ if (commentStringBuffer.length() > 0) { >+ commentStringBuffer.append(token.getWhitespace()); >+ } >+ commentStringBuffer.append((StringBuffer) token.getValue()); >+ } >+ // remove attachment description from comment body >+ if (comment.hasAttachment() && commentStringBuffer.indexOf(comment.getAttachmentDescription()) == 0) { >+ commentStringBuffer = new StringBuffer(); >+ } >+ } >+ >+ HtmlStreamTokenizer.unescape(commentStringBuffer); >+ comment.setText(commentStringBuffer.toString()); >+ bug.addComment(comment); >+ } >+ >+ private static void parseAttachment(StringBuffer stringBuffer, Comment comment, HtmlStreamTokenizer tokenizer, boolean obsolete) >+ throws IOException, ParseException { >+ >+ int attachmentID = -1; >+ String attachmentDescription = ""; >+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ >+ if (tag.getTagType() == HtmlTag.Type.A && !comment.hasAttachment()) { >+ if (tag.getAttribute(ATTRIBUTE_ID_HREF) != null) { >+ String link = tag.getAttribute(ATTRIBUTE_ID_HREF); >+ if (link.startsWith(ATTACHMENT_CGI_ID)) { >+ try { >+ int endIndex = link.indexOf("&"); >+ if (endIndex > 0 && endIndex < link.length()) { >+ attachmentID = Integer.parseInt(link >+ .substring(ATTACHMENT_CGI_ID.length(), endIndex)); >+ } >+ } catch (NumberFormatException e) { >+ return; >+ } >+ } >+ if (tag.getAttribute(ATTRIBUTE_ID_TITLE) != null) { >+ attachmentDescription = tag.getAttribute(ATTRIBUTE_ID_TITLE); >+ } >+ if (attachmentID > 0) { >+ comment.setHasAttachment(true); >+ comment.setAttachmentId(attachmentID); >+ comment.setAttachmentDescription(attachmentDescription); >+ comment.setObsolete(obsolete); >+ } >+ >+ } >+ } >+ if (tag.getTagName().equals(TAG_SPAN) && tag.isEndTag()) >+ break; >+ } >+ } >+ } >+ >+ /** >+ * Parse the full html version of the bug >+ * >+ * @param in - >+ * the input stream for the bug >+ * @param id - >+ * the id of the bug that is to be parsed >+ * @return A bug report for the bug that was parsed >+ * @throws IOException >+ * @throws ParseException >+ */ >+ public static BugReport parseBug(Reader in, int id, String serverUrl, boolean is218, String userName, >+ String password, String contentType) throws IOException, ParseException, LoginException { >+ // create a new bug report and set the parser state to the start state >+ BugReport bug = new BugReport(id, serverUrl); >+ boolean contentTypeResolved = false; >+ if (contentType != null) { >+ String charsetFromContentType = getCharsetFromString(contentType); >+ if (charsetFromContentType != null) { >+ bug.setCharset(charsetFromContentType); >+ contentTypeResolved = true; >+ } >+ } >+ ParserState state = ParserState.START; >+ Comment comment = null; >+ String attribute = null; >+ >+ HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(in, null); >+ >+ boolean isTitle = false; >+ boolean possibleBadLogin = false; >+ boolean checkBody = false; >+ String title = ""; >+ StringBuffer body = new StringBuffer(); >+ >+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >+ >+ // get the charset from the HTML if not specified >+ if (!contentTypeResolved) { >+ if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.META >+ && !((HtmlTag) (token.getValue())).isEndTag()) { >+ String charsetFromHtml = getCharsetFromString(token.toString()); >+ if (charsetFromHtml != null) >+ bug.setCharset(charsetFromHtml); >+ } >+ } >+ >+ // make sure that bugzilla doesn't want us to login >+ if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.TITLE >+ && !((HtmlTag) (token.getValue())).isEndTag()) { >+ isTitle = true; >+ continue; >+ } >+ >+ if (isTitle) { >+ // get all of the data in the title tag >+ if (token.getType() != Token.TAG) { >+ title += ((StringBuffer) token.getValue()).toString().toLowerCase() + " "; >+ continue; >+ } else if (token.getType() == Token.TAG >+ && ((HtmlTag) token.getValue()).getTagType() == HtmlTag.Type.TITLE >+ && ((HtmlTag) token.getValue()).isEndTag()) { >+ // check and see if the title seems as though we have wrong >+ // login info >+ if (title.indexOf("login") != -1 >+ || (title.indexOf("invalid") != -1 && title.indexOf("password") != -1) >+ || title.indexOf("check e-mail") != -1) >+ possibleBadLogin = true; // we possibly have a bad >+ // login >+ >+ // if the title starts with error, we may have a login >+ // problem, or >+ // there is a problem with the bug (doesn't exist), so we >+ // must do >+ // some more checks >+ if (title.startsWith("error")) >+ checkBody = true; >+ >+ isTitle = false; >+ title = ""; >+ } >+ continue; >+ } >+ >+ // if we have to add all of the text so that we can check it later >+ // for problems with the username and password >+ if (checkBody && token.getType() == Token.TEXT) { >+ body.append((StringBuffer) token.getValue()); >+ body.append(" "); >+ } >+ >+ // we have found the start of an attribute name >+ if ((state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.TD && "right".equalsIgnoreCase(tag.getAttribute("align"))) { >+ // parse the attribute's name >+ attribute = parseAttributeName(tokenizer); >+ if (attribute != null && attribute.contains(IBugzillaConstants.INVALID_2201_ATTRIBUTE_IGNORED)) { >+ continue; >+ } >+ if (attribute.toLowerCase().startsWith("opened")) { >+ // find the colon so we can get the date >+ int index = attribute.toLowerCase().indexOf(":"); >+ String date; >+ if (index != -1) >+ date = attribute.substring(index + 1).trim(); >+ else >+ date = attribute.substring(6).trim(); >+ >+ // set the bugs opened date to be the date we parsed >+ bug.setCreated(df.parse(date)); >+ state = ParserState.ATT_NAME; >+ continue; >+ } >+ >+ // in 2.18, the last modified looks like the opened so we >+ // need to parse it differently >+ if (attribute.toLowerCase().startsWith("last modified") && is218) { >+ // find the colon so we can get the date >+ int index = attribute.toLowerCase().indexOf(":"); >+ String date; >+ if (index != -1) >+ date = attribute.substring(index + 1).trim(); >+ else >+ date = attribute.substring(6).trim(); >+ >+ // create a new attribute and set the date >+ AbstractRepositoryReportAttribute t = new AbstractRepositoryReportAttribute("Last Modified"); >+ t.setValue(date); >+ >+ // add the attribute to the bug report >+ bug.addAttribute(t); >+ bug.setLastModified(df.parse(date)); >+ state = ParserState.ATT_NAME; >+ continue; >+ } >+ >+ state = ParserState.ATT_VALUE; >+ continue; >+ } else if (tag.getTagType() == HtmlTag.Type.INPUT && "radio".equalsIgnoreCase(tag.getAttribute("type")) >+ && "knob".equalsIgnoreCase(tag.getAttribute(KEY_NAME))) { >+ // we found a radio button >+ parseOperations(bug, tokenizer, tag, is218); >+ } >+ } >+ >+ // we have found the start of attribute values >+ if (state == ParserState.ATT_VALUE && token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.TD) { >+ // parse the attribute values >+ parseAttributeValue(bug, attribute, tokenizer, serverUrl, userName, password); >+ >+ state = ParserState.ATT_NAME; >+ attribute = null; >+ continue; >+ } >+ } >+ >+ // we have found the start of a comment >+ if (state == ParserState.DESC_START && token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.I) { >+ // parse the comment's start >+ comment = parseCommentHead(bug, tokenizer); >+ >+ state = ParserState.DESC_VALUE; >+ continue; >+ } >+ } >+ >+ // we have found the start of the comment text >+ if (state == ParserState.DESC_VALUE && token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.PRE) { >+ // parse the text of the comment >+ parseCommentText(bug, comment, tokenizer); >+ >+ comment = null; >+ state = ParserState.DESC_START; >+ continue; >+ } >+ } >+ >+ // last modification date >+ if (bug.getCreated() == null && (state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.DIV && tag.getAttribute("id") != null && "header".equalsIgnoreCase(tag.getAttribute("id"))) { >+ StringBuffer sb = new StringBuffer(); >+ parseLastModified(sb, tokenizer); >+ if(sb.length() > 0) { >+ int index = sb.indexOf(":"); >+ String date; >+ if (index != -1) >+ date = sb.substring(index + 1).trim(); >+ else >+ date = sb.substring(6).trim(); >+ >+ // create a new attribute and set the date >+ AbstractRepositoryReportAttribute t = new AbstractRepositoryReportAttribute("Last Modified"); >+ t.setValue(date); >+ >+ // add the attribute to the bug report >+ bug.setLastModified(df.parse(date)); >+ bug.addAttribute(t); >+ } >+ continue; >+ } >+ } >+ >+ >+ // look for date opened field >+ if (bug.getCreated() == null && (state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.TD && tag.getAttribute("align") != null && "left".equalsIgnoreCase(tag.getAttribute("align")) && tag.getAttribute("width") != null && "30%".equals(tag.getAttribute("width"))) { >+ StringBuffer sb = new StringBuffer(); >+ parseDateOpened(sb, tokenizer); >+ if(sb.length() > 0) { >+ int index = sb.indexOf(":"); >+ String date; >+ if (index != -1) >+ date = sb.substring(index + 1).trim(); >+ else >+ date = sb.substring(6).trim(); >+ >+ // set the bugs opened date to be the date we parsed >+ bug.setCreated(df.parse(date)); >+ } >+ continue; >+ } >+ } >+ >+ // we have found the description of the bug >+ if ((state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.PRE) { >+ // parse the description for the bug >+ parseDescription(bug, tokenizer); >+ >+ state = ParserState.DESC_START; >+ continue; >+ } >+ } >+ >+ // parse hidden fields >+ >+ if ((state == ParserState.ATT_NAME || state == ParserState.START) && token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.INPUT && tag.getAttribute("type") != null >+ && "hidden".equalsIgnoreCase(tag.getAttribute("type").trim())) { >+ >+ AbstractRepositoryReportAttribute a = new AbstractRepositoryReportAttribute(tag.getAttribute(KEY_NAME)); >+ a.setID(tag.getAttribute(KEY_NAME)); >+ a.setValue(tag.getAttribute(KEY_VALUE)); >+ a.setHidden(true); >+ bug.addAttribute(a); >+ continue; >+ } >+ } >+ >+ // // parse out attachments >+ // if(token.getType() == Token.TAG) { >+ // HtmlTag tag = (HtmlTag) token.getValue(); >+ // if(tag.getTagType() == HtmlTag.Type.A && tag.getAttribute("href") >+ // != null) { >+ // String link = tag.getAttribute("href"); >+ // if(link.startsWith("attachment.cgi?id=") && >+ // !link.contains("action")) { >+ // int attachmentID = Integer.parseInt(link.substring(18)); >+ // String description = parseAttachementDescription(tokenizer); >+ // bug.addAttachment(attachmentID, description); >+ // } >+ // } >+ // } >+ >+ } >+ >+ // if we are to check the body, make sure that there wasn't a bad login >+ if (checkBody) { >+ String b = body.toString(); >+ if (b.indexOf("login") != -1 >+ || ((b.indexOf("invalid") != -1 || b.indexOf("not valid") != -1) && b.indexOf("password") != -1) >+ || b.indexOf("check e-mail") != -1) >+ possibleBadLogin = true; // we possibly have a bad login >+ } >+ >+ // if there is no summary or created date, we expect that >+ // the bug doesn't exist, so set it to null >+ >+ // if the bug seems like it doesn't exist, and we suspect a login >+ // problem, assume that there was a login problem >+ if (bug.getCreated() == null && bug.getAttributes().isEmpty()) { >+ if (possibleBadLogin) { >+ throw new LoginException(IBugzillaConstants.MESSAGE_LOGIN_FAILURE); >+ } else { >+ return null; >+ } >+ } >+ // we are done...return the bug >+ return bug; >+ } >+ >+ private static void parseDateOpened(StringBuffer sb, HtmlStreamTokenizer tokenizer) throws IOException, ParseException { >+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.TD && tag.isEndTag()) >+ break; >+ } else if (token.getType() == Token.TEXT) { >+ if (sb.length() > 0) { >+ sb.append(' '); >+ } >+ sb.append((StringBuffer) token.getValue()); >+ } >+ } >+ >+ } >+ >+ private static void parseLastModified(StringBuffer sb, HtmlStreamTokenizer tokenizer) throws IOException, ParseException { >+ boolean inH3 = false; >+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >+ if (token.getType() == Token.TAG) { >+ HtmlTag tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.H3 && !tag.isEndTag()) { >+ inH3 = true; >+ continue; >+ } else if (tag.getTagType() == HtmlTag.Type.DIV && tag.isEndTag()) { >+ break; >+ } >+ } else if (token.getType() == Token.TEXT && inH3) { >+ if (sb.length() > 0) { >+ sb.append(' '); >+ } >+ sb.append((StringBuffer) token.getValue()); >+ } >+ } >+ >+ } >+ >+ public static String getCharsetFromString(String string) { >+ int charsetStartIndex = string.indexOf(ATTR_CHARSET); >+ if (charsetStartIndex != -1) { >+ int charsetEndIndex = string.indexOf("\"", charsetStartIndex); // TODO: >+ // could >+ // be >+ // space >+ // after? >+ if (charsetEndIndex == -1) { >+ charsetEndIndex = string.length(); >+ } >+ String charsetString = string.substring(charsetStartIndex + 8, charsetEndIndex); >+ if (Charset.availableCharsets().containsKey(charsetString)) { >+ return charsetString; >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Parse the operations that are allowed on the bug (Assign, Re-open, fix) >+ * >+ * @param bug >+ * The bug to add the operations to >+ * @param tokenizer >+ * The stream tokenizer for the bug >+ * @param tag >+ * The last tag that we were on >+ */ >+ private static void parseOperations(BugReport bug, HtmlStreamTokenizer tokenizer, HtmlTag tag, boolean is218) >+ throws ParseException, IOException { >+ >+ String knobName = tag.getAttribute(KEY_VALUE); >+ boolean isChecked = false; >+ if (tag.getAttribute("checked") != null && tag.getAttribute("checked").equals("checked")) >+ isChecked = true; >+ StringBuffer sb = new StringBuffer(); >+ >+ Token lastTag = null; >+ >+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { >+ if (token.getType() == Token.TAG) { >+ tag = (HtmlTag) token.getValue(); >+ >+ if (!(tag.getTagType() == HtmlTag.Type.A || tag.getTagType() == HtmlTag.Type.B >+ || tag.getTagType() == HtmlTag.Type.STRONG || tag.getTagType() == HtmlTag.Type.LABEL)) { >+ lastTag = token; >+ break; >+ } else { >+ >+ if (is218 && tag.getTagType() == HtmlTag.Type.LABEL) { >+ continue; >+ } else if (tag.getTagType() == HtmlTag.Type.A || tag.getTagType() == HtmlTag.Type.B >+ || tag.getTagType() == HtmlTag.Type.STRONG) { >+ sb.append(tag.toString().trim() + " "); >+ } else { >+ break; >+ } >+ } >+ } else if (token.getType() == Token.TEXT && !token.toString().trim().equals("\n")) >+ sb.append(token.toString().trim() + " "); >+ } >+ >+ String displayName = HtmlStreamTokenizer.unescape(sb).toString(); >+ Operation o = new Operation(knobName, displayName); >+ o.setChecked(isChecked); >+ >+ if (lastTag != null) { >+ tag = (HtmlTag) lastTag.getValue(); >+ if (tag.getTagType() != HtmlTag.Type.SELECT) { >+ tokenizer.pushback(lastTag); >+ if (tag.getTagType() == HtmlTag.Type.INPUT >+ && !("radio".equalsIgnoreCase(tag.getAttribute("type")) && "knob".equalsIgnoreCase(tag >+ .getAttribute(KEY_NAME)))) { >+ o.setInputName(((HtmlTag) lastTag.getValue()).getAttribute(KEY_NAME)); >+ o.setInputValue(((HtmlTag) lastTag.getValue()).getAttribute(KEY_VALUE)); >+ } >+ } else { >+ Token token = tokenizer.nextToken(); >+ // parse the options >+ >+ tag = (HtmlTag) token.getValue(); >+ o.setUpOptions(((HtmlTag) lastTag.getValue()).getAttribute(KEY_NAME)); >+ >+ while (token.getType() != Token.EOF) { >+ if (token.getType() == Token.TAG) { >+ tag = (HtmlTag) token.getValue(); >+ if (tag.getTagType() == HtmlTag.Type.SELECT && tag.isEndTag()) >+ break; >+ if (tag.getTagType() == HtmlTag.Type.OPTION && !tag.isEndTag()) { >+ String optionName = tag.getAttribute(KEY_VALUE); >+ StringBuffer optionText = new StringBuffer(); >+ for (token = tokenizer.nextToken(); token.getType() == Token.TEXT; token = tokenizer >+ .nextToken()) { >+ if (optionText.length() > 0) { >+ optionText.append(' '); >+ } >+ optionText.append((StringBuffer) token.getValue()); >+ } >+ o.addOption(optionText.toString(), optionName); >+ } else { >+ token = tokenizer.nextToken(); >+ } >+ } else { >+ token = tokenizer.nextToken(); >+ } >+ } >+ } >+ } >+ >+ bug.addOperation(o); >+ } >+ >+ /** >+ * Enum class for describing current state of Bugzilla report parser. >+ */ >+ private static class ParserState { >+ /** An instance of the start state */ >+ protected static final ParserState START = new ParserState("start"); >+ >+ /** An instance of the state when the parser found an attribute name */ >+ protected static final ParserState ATT_NAME = new ParserState("att_name"); >+ >+ /** An instance of the state when the parser found an attribute value */ >+ protected static final ParserState ATT_VALUE = new ParserState("att_value"); >+ >+ /** An instance of the state when the parser found a description */ >+ protected static final ParserState DESC_START = new ParserState("desc_start"); >+ >+ /** An instance of the state when the parser found a description value */ >+ protected static final ParserState DESC_VALUE = new ParserState("desc_value"); >+ >+ /** State's human-readable name */ >+ private String name; >+ >+ /** >+ * Constructor >+ * >+ * @param description - >+ * The states human readable name >+ */ >+ private ParserState(String description) { >+ this.name = description; >+ } >+ >+ @Override >+ public String toString() { >+ return name; >+ } >+ } >+} >Index: developer/scratch/bugzilla/BugzillaNewBugParserTestEquinox.java >=================================================================== >RCS file: developer/scratch/bugzilla/BugzillaNewBugParserTestEquinox.java >diff -N developer/scratch/bugzilla/BugzillaNewBugParserTestEquinox.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ developer/scratch/bugzilla/BugzillaNewBugParserTestEquinox.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,219 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.tests; >+ >+import java.io.File; >+import java.io.FileReader; >+import java.io.Reader; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.core.runtime.Path; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.core.tests.support.FileTool; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; >+import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; >+ >+/** >+ * Tests NewBugParser -- parses product attributes >+ */ >+public class BugzillaNewBugParserTestEquinox extends TestCase { >+ >+ public BugzillaNewBugParserTestEquinox() { >+ super(); >+ } >+ >+ public BugzillaNewBugParserTestEquinox(String arg0) { >+ super(arg0); >+ } >+ >+ public void testProductEquinox() throws Exception { >+ >+ File f = FileTool >+ .getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/equinox-page.html")); >+ >+ Reader in = new FileReader(f); >+ >+ NewBugzillaReport nbm = new NewBugzillaReport(); >+ new NewBugParser(in).parseBugAttributes(nbm, true); // ** TRUE vs FALSE >+ // ** >+ >+ // attributes for this bug model >+ List<AbstractRepositoryReportAttribute> attributes = nbm.getAttributes(); >+ // printList(attributes); >+ >+ Iterator<AbstractRepositoryReportAttribute> itr = attributes.iterator(); >+ AbstractRepositoryReportAttribute att = itr.next(); >+ >+ // Attribute: Severity >+ assertEquals("Attribute: Severity", "Severity", att.getName()); >+ >+ Map<String, String> attOptions = att.getOptionValues(); // HashMap of >+ // options for the >+ // current >+ // attribute >+ Object[] options = attOptions.keySet().toArray(); // Array of keys for >+ // the options of the >+ // current attribute >+ assertEquals("# Severity options", 7, options.length); >+ >+ int i = 0; >+ while (i < options.length) { >+ assertEquals("severity options", "blocker", options[i++]); >+ assertEquals("severity options", "critical", options[i++]); >+ assertEquals("severity options", "major", options[i++]); >+ assertEquals("severity options", "normal", options[i++]); >+ assertEquals("severity options", "minor", options[i++]); >+ assertEquals("severity options", "trivial", options[i++]); >+ assertEquals("severity options", "enhancement", options[i++]); >+ } >+ >+ // Attribute: product >+ att = itr.next(); >+ assertEquals("Attribute: prodcut", "product", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No product options", 0, options.length); >+ >+ // Attribute: AssignedTo >+ att = itr.next(); >+ assertEquals("Attribute: AssignedTo", "AssignedTo", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No AssignedTo options", 0, options.length); >+ >+ // Attribute: OS >+ att = itr.next(); >+ assertEquals("Attribute: OS", "OS", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# OS options", 20, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("OS options", "All", options[i++]); >+ assertEquals("OS options", "AIX Motif", options[i++]); >+ assertEquals("OS options", "Windows 95", options[i++]); >+ assertEquals("OS options", "Windows 98", options[i++]); >+ assertEquals("OS options", "Windows CE", options[i++]); >+ assertEquals("OS options", "Windows ME", options[i++]); >+ assertEquals("OS options", "Windows 2000", options[i++]); >+ assertEquals("OS options", "Windows NT", options[i++]); >+ assertEquals("OS options", "Windows XP", options[i++]); >+ assertEquals("OS options", "Windows All", options[i++]); >+ assertEquals("OS options", "MacOS X", options[i++]); >+ assertEquals("OS options", "Linux", options[i++]); >+ assertEquals("OS options", "Linux-GTK", options[i++]); >+ assertEquals("OS options", "Linux-Motif", options[i++]); >+ assertEquals("OS options", "HP-UX", options[i++]); >+ assertEquals("OS options", "Neutrino", options[i++]); >+ assertEquals("OS options", "QNX-Photon", options[i++]); >+ assertEquals("OS options", "Solaris", options[i++]); >+ assertEquals("OS options", "Unix All", options[i++]); >+ assertEquals("OS options", "other", options[i++]); >+ } >+ >+ // Attribute: Version >+ att = itr.next(); >+ assertEquals("Attribute: Version", "Version", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# Version options", 1, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Version options", "unspecified", options[i++]); >+ } >+ >+ // Attribute: Platform >+ att = itr.next(); >+ assertEquals("Attribute: Platform", "Platform", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# Platform options", 6, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Platform options", "All", options[i++]); >+ assertEquals("Platform options", "Macintosh", options[i++]); >+ assertEquals("Platform options", "PC", options[i++]); >+ assertEquals("Platform options", "Power PC", options[i++]); >+ assertEquals("Platform options", "Sun", options[i++]); >+ assertEquals("Platform options", "Other", options[i++]); >+ } >+ >+ // Attribute: Component >+ att = itr.next(); >+ assertEquals("Attribute: Component", "Component", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("# Component options", 3, options.length); >+ >+ i = 0; >+ while (i < options.length) { >+ assertEquals("Component options", "Dynamic Plugins", options[i++]); >+ assertEquals("Component options", "General", options[i++]); >+ assertEquals("Component options", "OSGi", options[i++]); >+ } >+ >+ // Attribute: bug_status >+ att = itr.next(); >+ assertEquals("Attribute: bug_status", "bug_status", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No bug_status options", 0, options.length); >+ >+ // Attribute: form_name >+ att = itr.next(); >+ assertEquals("Attribute: form_name", "form_name", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No form_name options", 0, options.length); >+ >+ // Attribute: bug_file_loc >+ att = itr.next(); >+ assertEquals("Attribute: bug_file_loc", "bug_file_loc", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No bug_file_loc options", 0, options.length); >+ >+ // Attribute: priority >+ att = itr.next(); >+ assertEquals("Attribute: priority", "priority", att.getName()); >+ >+ options = att.getOptionValues().keySet().toArray(); >+ assertEquals("No priority options", 0, options.length); >+ >+ } >+ >+ // private void printList(List<Attribute> attributes) { >+ // >+ // Iterator<Attribute> itr = attributes.iterator(); >+ // System.out.println("Attributes for this Product:"); >+ // System.out.println("============================"); >+ // >+ // while (itr.hasNext()) { >+ // Attribute attr = itr.next(); >+ // System.out.println(); >+ // System.out.println(attr.getName() + ": "); >+ // System.out.println("-----------"); >+ // >+ // Map<String, String> options = attr.getOptionValues(); >+ // Object[] it = options.keySet().toArray(); >+ // for (int i = 0; i < it.length; i++) >+ // System.out.println((String) it[i]); >+ // } >+ // } >+} >#P org.eclipse.mylar.tasklist.tests >Index: src/org/eclipse/mylar/tasklist/tests/BugzillaTaskTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasklist.tests/src/org/eclipse/mylar/tasklist/tests/BugzillaTaskTest.java,v >retrieving revision 1.5 >diff -u -r1.5 BugzillaTaskTest.java >--- src/org/eclipse/mylar/tasklist/tests/BugzillaTaskTest.java 27 Jan 2006 02:37:57 -0000 1.5 >+++ src/org/eclipse/mylar/tasklist/tests/BugzillaTaskTest.java 8 May 2006 23:07:26 -0000 >@@ -11,14 +11,17 @@ > > package org.eclipse.mylar.tasklist.tests; > >+import java.util.Calendar; > import java.util.Date; > > import junit.framework.TestCase; > >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReportAttribute; > import org.eclipse.mylar.bugzilla.core.Comment; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; > import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaTask; > > /** >@@ -40,18 +43,27 @@ > > public void testCompletionDate() { > BugzillaTask task = new BugzillaTask("handle", "description", true); >- BugReport report = new BugReport(1, IBugzillaConstants.ECLIPSE_BUGZILLA_URL); >+ BugzillaReport report = new BugzillaReport(1, IBugzillaConstants.ECLIPSE_BUGZILLA_URL); > task.setBugReport(report); > assertNull(task.getCompletionDate()); > >- Date now = new Date(); >- report.addComment(new Comment(report, 1, now, "author", "author-name")); >+ Calendar calendar = Calendar.getInstance(); >+ calendar.set(Calendar.MILLISECOND, 0); >+ calendar.getTimeInMillis(); >+ Date now = new Date(calendar.getTimeInMillis()); >+ >+ Comment comment = new Comment(report, 1); >+ AbstractRepositoryReportAttribute attribute = new BugzillaReportAttribute(BugzillaReportElement.CREATION_TS); >+ attribute.setValue(Comment.creation_ts_date_format.format(now)); >+ comment.addAttribute(BugzillaReportElement.CREATION_TS, attribute); >+ report.addComment(comment); > assertNull(task.getCompletionDate()); > >- Attribute resolvedAttribute = new Attribute(BugReport.ATTR_STATUS); >- resolvedAttribute.setValue(BugReport.VAL_STATUS_RESOLVED); >- report.addAttribute(resolvedAttribute); >- assertEquals(now, task.getCompletionDate()); >+ AbstractRepositoryReportAttribute resolvedAttribute = new BugzillaReportAttribute(BugzillaReportElement.BUG_STATUS); >+ resolvedAttribute.setValue(BugzillaReport.VAL_STATUS_RESOLVED); >+ report.addAttribute(BugzillaReportElement.BUG_STATUS, resolvedAttribute); >+ assertNotNull(task.getCompletionDate()); >+ assertEquals(Comment.creation_ts_date_format.format(now), Comment.creation_ts_date_format.format(task.getCompletionDate())); > > } > >Index: src/org/eclipse/mylar/tasklist/tests/TaskTestUtil.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasklist.tests/src/org/eclipse/mylar/tasklist/tests/TaskTestUtil.java,v >retrieving revision 1.7 >diff -u -r1.7 TaskTestUtil.java >--- src/org/eclipse/mylar/tasklist/tests/TaskTestUtil.java 20 Feb 2006 02:32:49 -0000 1.7 >+++ src/org/eclipse/mylar/tasklist/tests/TaskTestUtil.java 8 May 2006 23:07:26 -0000 >@@ -21,10 +21,12 @@ > import java.util.Date; > > import org.eclipse.core.runtime.FileLocator; >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReportAttribute; > import org.eclipse.mylar.bugzilla.core.Comment; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; > import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaTask; > > /** >@@ -41,35 +43,41 @@ > return null; > } > } >- >+ > /** > * Adaptred from Java Developers' almanac > */ >- public static void copy(File source, File dest) throws IOException { >- InputStream in = new FileInputStream(source); >- OutputStream out = new FileOutputStream(dest); >- byte[] buf = new byte[1024]; >- int len; >- while ((len = in.read(buf)) > 0) { >- out.write(buf, 0, len); >- } >- in.close(); >- out.close(); >- } >- >+ public static void copy(File source, File dest) throws IOException { >+ InputStream in = new FileInputStream(source); >+ OutputStream out = new FileOutputStream(dest); >+ byte[] buf = new byte[1024]; >+ int len; >+ while ((len = in.read(buf)) > 0) { >+ out.write(buf, 0, len); >+ } >+ in.close(); >+ out.close(); >+ } >+ > public static void setBugTaskCompleted(BugzillaTask bugzillaTask, boolean completed) { >- BugReport report = new BugReport(1, IBugzillaConstants.ECLIPSE_BUGZILLA_URL); >+ BugzillaReport report = new BugzillaReport(1, IBugzillaConstants.ECLIPSE_BUGZILLA_URL); > bugzillaTask.setBugReport(report); >- Attribute resolvedAttribute = new Attribute(BugReport.ATTR_STATUS); >- if (completed) { >- resolvedAttribute.setValue(BugReport.VAL_STATUS_RESOLVED); >+ AbstractRepositoryReportAttribute resolvedAttribute = new BugzillaReportAttribute( >+ BugzillaReportElement.BUG_STATUS); >+ if (completed) { >+ resolvedAttribute.setValue(BugzillaReport.VAL_STATUS_RESOLVED); >+ Comment comment = new Comment(report, 1); >+ AbstractRepositoryReportAttribute attribute = new BugzillaReportAttribute(BugzillaReportElement.CREATION_TS); >+ attribute.setValue(Comment.creation_ts_date_format.format(new Date())); >+ comment.addAttribute(BugzillaReportElement.CREATION_TS, attribute); >+ report.addComment(comment); > } else { >- resolvedAttribute.setValue(BugReport.VAL_STATUS_NEW); >+ resolvedAttribute.setValue(BugzillaReport.VAL_STATUS_NEW); > } >- >- report.addAttribute(resolvedAttribute); >- >- Date now = new Date(); >- report.addComment(new Comment(report, 1, now, "author", "author-name")); >+ >+ report.addAttribute(BugzillaReportElement.BUG_STATUS, resolvedAttribute); >+ report.addComment(new Comment(report, 1)); >+ // report.addComment(new Comment(report, 1, now, "author", >+ // "author-name")); > } > } >#P org.eclipse.mylar.tasklist >Index: src/org/eclipse/mylar/provisional/tasklist/AbstractRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasklist/src/org/eclipse/mylar/provisional/tasklist/AbstractRepositoryConnector.java,v >retrieving revision 1.25 >diff -u -r1.25 AbstractRepositoryConnector.java >--- src/org/eclipse/mylar/provisional/tasklist/AbstractRepositoryConnector.java 28 Apr 2006 22:09:26 -0000 1.25 >+++ src/org/eclipse/mylar/provisional/tasklist/AbstractRepositoryConnector.java 8 May 2006 23:07:27 -0000 >@@ -84,7 +84,7 @@ > * set an exception on queryStatus.getChildren[0] to indicate > * failure > */ >- protected abstract List<AbstractQueryHit> performQuery(AbstractRepositoryQuery query, IProgressMonitor monitor, >+ public abstract List<AbstractQueryHit> performQuery(AbstractRepositoryQuery query, IProgressMonitor monitor, > MultiStatus queryStatus); > > protected abstract void updateOfflineState(AbstractRepositoryTask repositoryTask, boolean forceSync); >@@ -310,4 +310,6 @@ > "Opening JIRA issues not added to task list is not implemented." > ); > } >+ >+ > } >#P org.eclipse.mylar.bugs >Index: src/org/eclipse/mylar/internal/bugs/BugzillaContextLabelProvider.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugs/src/org/eclipse/mylar/internal/bugs/BugzillaContextLabelProvider.java,v >retrieving revision 1.4 >diff -u -r1.4 BugzillaContextLabelProvider.java >--- src/org/eclipse/mylar/internal/bugs/BugzillaContextLabelProvider.java 20 Feb 2006 19:52:52 -0000 1.4 >+++ src/org/eclipse/mylar/internal/bugs/BugzillaContextLabelProvider.java 8 May 2006 23:07:27 -0000 >@@ -11,7 +11,7 @@ > > package org.eclipse.mylar.internal.bugs; > >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.internal.bugs.search.BugzillaReferencesProvider; > import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaReportNode; > import org.eclipse.mylar.internal.tasklist.ui.TaskListImages; >@@ -56,7 +56,7 @@ > // try to get from the cache before downloading > Object report; > BugzillaReportNode reportNode = MylarBugsPlugin.getReferenceProvider().getCached(node.getHandleIdentifier()); >- BugReport cachedReport = MylarBugsPlugin.getDefault().getCache().getCached(node.getHandleIdentifier()); >+ BugzillaReport cachedReport = MylarBugsPlugin.getDefault().getCache().getCached(node.getHandleIdentifier()); > IMylarStructureBridge bridge = MylarPlugin.getDefault() > .getStructureBridge(BugzillaStructureBridge.CONTENT_TYPE); > >Index: src/org/eclipse/mylar/internal/bugs/BugzillaStructureBridge.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugs/src/org/eclipse/mylar/internal/bugs/BugzillaStructureBridge.java,v >retrieving revision 1.6 >diff -u -r1.6 BugzillaStructureBridge.java >--- src/org/eclipse/mylar/internal/bugs/BugzillaStructureBridge.java 9 Mar 2006 21:06:17 -0000 1.6 >+++ src/org/eclipse/mylar/internal/bugs/BugzillaStructureBridge.java 8 May 2006 23:07:27 -0000 >@@ -19,7 +19,7 @@ > import org.eclipse.core.resources.IProject; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.jface.operation.IRunnableWithProgress; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaTools; >@@ -75,7 +75,7 @@ > return null; > } > >- private BugReport result; >+ private BugzillaReport result; > > /** > * TODO: this will not return a non-cached handle >Index: src/org/eclipse/mylar/internal/bugs/BugzillaReportCache.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugs/src/org/eclipse/mylar/internal/bugs/BugzillaReportCache.java,v >retrieving revision 1.2 >diff -u -r1.2 BugzillaReportCache.java >--- src/org/eclipse/mylar/internal/bugs/BugzillaReportCache.java 7 Feb 2006 17:38:15 -0000 1.2 >+++ src/org/eclipse/mylar/internal/bugs/BugzillaReportCache.java 8 May 2006 23:07:27 -0000 >@@ -18,8 +18,7 @@ > > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.Platform; >-import org.eclipse.mylar.bugzilla.core.BugReport; >-import org.eclipse.mylar.bugzilla.core.IBugzillaBug; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaTools; > import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaCacheFile; > import org.eclipse.mylar.internal.core.util.MylarStatusHandler; >@@ -29,9 +28,9 @@ > */ > public class BugzillaReportCache { > >- private Map<String, BugReport> cache = new HashMap<String, BugReport>(); >+ private Map<String, BugzillaReport> cache = new HashMap<String, BugzillaReport>(); > >- public void cache(String handle, BugReport report) { >+ public void cache(String handle, BugzillaReport report) { > cache.put(handle, report); > cacheFile.add(report); > } >@@ -41,7 +40,7 @@ > cacheFile.removeAll(); > } > >- public BugReport getFromCache(String bugHandle) { >+ public BugzillaReport getFromCache(String bugHandle) { > return cache.get(bugHandle); > } > >@@ -62,17 +61,17 @@ > > try { > cacheFile = new BugzillaCacheFile(cachPath.toFile()); >- ArrayList<IBugzillaBug> cached = cacheFile.elements(); >- for (IBugzillaBug bug : cached) { >- if (bug instanceof BugReport) >- cache.put(BugzillaTools.getHandle(bug), (BugReport) bug); >+ ArrayList<BugzillaReport> cached = cacheFile.elements(); >+ for (BugzillaReport bug : cached) { >+ if (bug instanceof BugzillaReport) >+ cache.put(BugzillaTools.getHandle(bug), (BugzillaReport) bug); > } > } catch (Exception e) { > MylarStatusHandler.log(e, "occurred while restoring saved offline Bugzilla reports."); > } > } > >- public BugReport getCached(String handle) { >+ public BugzillaReport getCached(String handle) { > return cache.get(handle); > } > } >Index: src/org/eclipse/mylar/internal/bugs/search/BugzillaMylarSearchOperation.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugs/src/org/eclipse/mylar/internal/bugs/search/BugzillaMylarSearchOperation.java,v >retrieving revision 1.7 >diff -u -r1.7 BugzillaMylarSearchOperation.java >--- src/org/eclipse/mylar/internal/bugs/search/BugzillaMylarSearchOperation.java 13 Mar 2006 15:59:58 -0000 1.7 >+++ src/org/eclipse/mylar/internal/bugs/search/BugzillaMylarSearchOperation.java 8 May 2006 23:07:27 -0000 >@@ -28,7 +28,7 @@ > import org.eclipse.jdt.core.IMember; > import org.eclipse.jdt.core.IType; > import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.bugzilla.core.Comment; > import org.eclipse.mylar.internal.bugs.MylarBugsPlugin; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; >@@ -220,7 +220,7 @@ > > // we have a bugzilla task, so get the bug report > BugzillaTask bugTask = (BugzillaTask) task; >- BugReport bug = bugTask.getBugReport(); >+ BugzillaReport bug = bugTask.getBugReport(); > > // parse the bug report for the element that we are searching > // for >@@ -252,7 +252,7 @@ > * @param bug > * The bug to search in > */ >- private boolean search(String elementName, BugReport bug) { >+ private boolean search(String elementName, BugzillaReport bug) { > > if (bug == null) > return false; // MIK: added null check here >@@ -373,7 +373,7 @@ > > // get the bug report so that we have all of the data > // - descriptions, comments, etc >- BugReport b = null; >+ BugzillaReport b = null; > try { > b = info.getBug(); > } catch (Exception e) { >#P org.eclipse.mylar.ui >Index: src/org/eclipse/mylar/internal/ui/actions/ContextAttachAction.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.ui/src/org/eclipse/mylar/internal/ui/actions/ContextAttachAction.java,v >retrieving revision 1.4 >diff -u -r1.4 ContextAttachAction.java >--- src/org/eclipse/mylar/internal/ui/actions/ContextAttachAction.java 28 Apr 2006 02:21:05 -0000 1.4 >+++ src/org/eclipse/mylar/internal/ui/actions/ContextAttachAction.java 8 May 2006 23:07:28 -0000 >@@ -13,13 +13,11 @@ > > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.wizard.WizardDialog; > import org.eclipse.mylar.internal.core.util.MylarStatusHandler; > import org.eclipse.mylar.internal.tasklist.ui.views.TaskListView; > import org.eclipse.mylar.internal.tasklist.ui.wizards.ContextAttachWizard; >-import org.eclipse.mylar.provisional.core.MylarPlugin; > import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryTask; > import org.eclipse.mylar.provisional.tasklist.ITask; > import org.eclipse.swt.widgets.Shell; >@@ -44,12 +42,7 @@ > public void run(IAction action) { > ITask task = TaskListView.getDefault().getSelectedTask(); > if (task instanceof AbstractRepositoryTask) { >- try { >- if (!MylarPlugin.getContextManager().hasContext(task.getHandleIdentifier())) { >- MessageDialog.openInformation(null, "Attach Context", "No context exists for selected task."); >- return; >- } >- >+ try { > ContextAttachWizard wizard = new ContextAttachWizard((AbstractRepositoryTask)task); > Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); > if (wizard != null && shell != null && !shell.isDisposed()) { >#P org.eclipse.mylar.bugzilla.tests >Index: src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestCDT.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestCDT.java >diff -N src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestCDT.java >--- src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestCDT.java 22 Feb 2006 22:35:14 -0000 1.6 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,213 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylar.bugzilla.tests; >- >-import java.io.File; >-import java.io.FileReader; >-import java.io.Reader; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Map; >- >-import junit.framework.TestCase; >- >-import org.eclipse.core.runtime.Path; >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.core.tests.support.FileTool; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >-import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; >- >-/** >- * Tests NewBugParser -- parses product attributes for new bug reports >- */ >-public class BugzillaNewBugParserTestCDT extends TestCase { >- >- public BugzillaNewBugParserTestCDT() { >- super(); >- } >- >- public BugzillaNewBugParserTestCDT(String arg0) { >- super(arg0); >- } >- >- public void testProductCDT() throws Exception { >- >- File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/cdt-page.html")); >- >- Reader in = new FileReader(f); >- >- NewBugModel nbm = new NewBugModel(); >- new NewBugParser(in).parseBugAttributes(nbm, true); // ** TRUE vs FALSE >- // ** >- >- // attributes for this bug model >- List<Attribute> attributes = nbm.getAttributes(); >- // printList(attributes); >- >- Iterator<Attribute> itr = attributes.iterator(); >- Attribute att = itr.next(); >- >- // Attribute: Severity >- assertEquals("Attribute: Severity", "Severity", att.getName()); >- >- Map<String, String> attOptions = att.getOptionValues(); // HashMap of >- // options for the >- // current >- // attribute >- Object[] options = attOptions.keySet().toArray(); // Array of keys for >- // the options of the >- // current attribute >- assertEquals("# Severity options", 7, options.length); >- >- int i = 0; >- while (i < options.length) { >- assertEquals("severity options", "blocker", options[i++]); >- assertEquals("severity options", "critical", options[i++]); >- assertEquals("severity options", "major", options[i++]); >- assertEquals("severity options", "normal", options[i++]); >- assertEquals("severity options", "minor", options[i++]); >- assertEquals("severity options", "trivial", options[i++]); >- assertEquals("severity options", "enhancement", options[i++]); >- } >- >- // Attribute: product >- att = itr.next(); >- assertEquals("Attribute: product", "product", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("No product options", 0, options.length); >- >- // Attribute: AssignedTo >- att = itr.next(); >- assertEquals("Attribute: AssignedTo", "AssignedTo", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("No AssignedTo options", 0, options.length); >- >- // Attribute: OS >- att = itr.next(); >- assertEquals("Attribute: OS", "OS", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("# of options", 20, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("OS options", "All", options[i++]); >- assertEquals("OS options", "AIX Motif", options[i++]); >- assertEquals("OS options", "Windows 95", options[i++]); >- assertEquals("OS options", "Windows 98", options[i++]); >- assertEquals("OS options", "Windows CE", options[i++]); >- assertEquals("OS options", "Windows ME", options[i++]); >- assertEquals("OS options", "Windows 2000", options[i++]); >- assertEquals("OS options", "Windows NT", options[i++]); >- assertEquals("OS options", "Windows XP", options[i++]); >- assertEquals("OS options", "Windows All", options[i++]); >- assertEquals("OS options", "MacOS X", options[i++]); >- assertEquals("OS options", "Linux", options[i++]); >- assertEquals("OS options", "Linux-GTK", options[i++]); >- assertEquals("OS options", "Linux-Motif", options[i++]); >- assertEquals("OS options", "HP-UX", options[i++]); >- assertEquals("OS options", "Neutrino", options[i++]); >- assertEquals("OS options", "QNX-Photon", options[i++]); >- assertEquals("OS options", "Solaris", options[i++]); >- assertEquals("OS options", "Unix All", options[i++]); >- assertEquals("OS options", "other", options[i++]); >- } >- >- // Attribute: Version >- att = itr.next(); >- assertEquals("Attribute: Version", "Version", att.getName()); >- >- // attOptions = (HashMap) att.getOptionValues(); >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# Version options", 5, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Version options", "1.0", options[i++]); >- assertEquals("Version options", "1.0.1", options[i++]); >- assertEquals("Version options", "1.1", options[i++]); >- assertEquals("Version options", "1.2", options[i++]); >- assertEquals("Version options", "2.0", options[i++]); >- } >- >- // Attribute: Platform >- att = itr.next(); >- assertEquals("Attribute: Platform", "Platform", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# Platform options", 6, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Platform options", "All", options[i++]); >- assertEquals("Platform options", "Macintosh", options[i++]); >- assertEquals("Platform options", "PC", options[i++]); >- assertEquals("Platform options", "Power PC", options[i++]); >- assertEquals("Platform options", "Sun", options[i++]); >- assertEquals("Platform options", "Other", options[i++]); >- } >- >- // Attribute: Component >- att = itr.next(); >- assertEquals("Attribute: Component", "Component", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# Component options", 9, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Component options", "CDT-parser", options[i++]); >- assertEquals("Component options", "Core", options[i++]); >- assertEquals("Component options", "Cpp-Extensions", options[i++]); >- assertEquals("Component options", "Debug", options[i++]); >- assertEquals("Component options", "Debug-MI", options[i++]); >- assertEquals("Component options", "Doc", options[i++]); >- assertEquals("Component options", "Generic-Extensions", options[i++]); >- assertEquals("Component options", "Launcher", options[i++]); >- assertEquals("Component options", "UI", options[i++]); >- } >- >- // Attribute: bug_status >- att = itr.next(); >- assertEquals("Attribute: bug_status", "bug_status", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# bug_status options [none]", 0, options.length); >- >- // Attribute: form_name >- att = itr.next(); >- assertEquals("Attribute: form_name", "form_name", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No form_name options", 0, options.length); >- >- // Attribute: bug_file_loc >- att = itr.next(); >- assertEquals("Attribute: bug_file_loc", "bug_file_loc", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No bug_file_loc options", 0, options.length); >- >- // Attribute: priority >- att = itr.next(); >- assertEquals("Attribute: priority", "priority", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No priority options", 0, options.length); >- >- } >-} >Index: src/org/eclipse/mylar/bugzilla/tests/Bugzilla220ParserTest.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/tests/Bugzilla220ParserTest.java >diff -N src/org/eclipse/mylar/bugzilla/tests/Bugzilla220ParserTest.java >--- src/org/eclipse/mylar/bugzilla/tests/Bugzilla220ParserTest.java 29 Mar 2006 02:06:18 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,92 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylar.bugzilla.tests; >- >-import java.io.File; >-import java.io.FileReader; >-import java.io.Reader; >- >-import junit.framework.TestCase; >- >-import org.eclipse.core.runtime.Path; >-import org.eclipse.mylar.bugzilla.core.BugReport; >-import org.eclipse.mylar.core.tests.support.FileTool; >-import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >-import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser; >-import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; >- >-/** >- * @author Mik Kersten >- * @author Rob Elves >- */ >-public class Bugzilla220ParserTest extends TestCase { >- >- public static final String TEST_SERVER = IBugzillaConstants.ECLIPSE_BUGZILLA_URL; >- >- private static final String PRODUCT_MYLAR = "Mylar"; >- >- private static final String PRODUCT_TEST = "TestProduct"; >- >- public void testId220() throws Exception { >- >- File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( >- "testdata/pages/test-report-220.html")); >- Reader in = new FileReader(f); >- >- BugReport bug = BugParser.parseBug(in, 7, TEST_SERVER, false, null, null, null); >- >- assertEquals(7, bug.getId()); >- assertEquals("summary", bug.getSummary()); >- assertEquals("7", bug.getAttribute("Bug#").getValue()); >- assertEquals("7", bug.getAttribute("id").getValue()); >- } >- >- public void testId2201() throws Exception { >- >- File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( >- "testdata/pages/test-report-2201.html")); >- Reader in = new FileReader(f); >- >- BugReport bug = BugParser.parseBug(in, 125527, TEST_SERVER, false, null, null, null); >- >- assertEquals(125527, bug.getId()); >- assertEquals("bugzilla refresh incorrect for new reports and newly opened hits", bug.getSummary()); >- assertEquals("125527", bug.getAttribute("Bug#").getValue()); >- assertEquals("125527", bug.getAttribute("id").getValue()); >- } >- >- public void testNewBugProduct220() throws Exception { >- >- NewBugModel nbm = new NewBugModel(); >- >- File f = FileTool >- .getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/enter-bug220.html")); >- Reader in = new FileReader(f); >- >- new NewBugParser(in).parseBugAttributes(nbm, true); >- assertEquals(PRODUCT_TEST, nbm.getAttribute("product").getValue()); >- } >- >- public void testNewBugProduct2201() throws Exception { >- >- NewBugModel nbm = new NewBugModel(); >- >- File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), >- new Path("testdata/pages/enter-bug2201.html")); >- Reader in = new FileReader(f); >- >- new NewBugParser(in).parseBugAttributes(nbm, true); >- assertEquals(PRODUCT_MYLAR, nbm.getAttribute("product").getValue()); >- } >- >-} >Index: src/org/eclipse/mylar/bugzilla/tests/ReportAttachmentTest.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/tests/ReportAttachmentTest.java >diff -N src/org/eclipse/mylar/bugzilla/tests/ReportAttachmentTest.java >--- src/org/eclipse/mylar/bugzilla/tests/ReportAttachmentTest.java 8 Apr 2006 03:31:40 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,77 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylar.bugzilla.tests; >- >-import java.io.File; >-import java.io.FileReader; >-import java.io.Reader; >-import java.net.URL; >- >-import junit.framework.TestCase; >- >-import org.eclipse.core.runtime.FileLocator; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.mylar.bugzilla.core.BugReport; >-import org.eclipse.mylar.core.tests.support.FileTool; >-import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; >-import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; >-import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >-import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser; >-import org.eclipse.mylar.provisional.tasklist.TaskRepository; >- >-/** >- * @author Rob Elves >- */ >-public class ReportAttachmentTest extends TestCase { >- >- public void testExistingBugWithAttachment() throws Exception { >- File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( >- "testdata/pages/test-report-222attachment.html")); >- Reader in = new FileReader(f); >- >- BugReport bug = BugParser.parseBug(in, 4, IBugzillaConstants.ECLIPSE_BUGZILLA_URL, false, null, null, null); >- >- assertEquals(4, bug.getId()); >- assertEquals("4", bug.getAttribute("Bug#").getValue()); >- assertEquals("4", bug.getAttribute("id").getValue()); >- >- assertNotNull(bug.getComments()); >- assertEquals(1, bug.getComments().size()); >- assertTrue(bug.getComments().get(0).hasAttachment()); >- assertEquals("Testing upload", bug.getComments().get(0).getAttachmentDescription()); >-// System.err.println(bug.getComments().get(0).getText()); >-// assertEquals(1, bug.getAttachements().size()); >-// assertEquals("Testing upload", bug.getAttachements().get(1)); >- } >- >- public void testAttachementDownload() throws Exception { >- URL localURL = null; >- URL installURL = BugzillaTestPlugin.getDefault().getBundle().getEntry("testdata/contexts/"); >-// File destinationFile = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/contexts/")); >- localURL = FileLocator.toFileURL(installURL); >- File destinationFile = new File(localURL.getPath()+"downloadedContext.xml"); >- >- TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL); >- boolean result = BugzillaRepositoryUtil.downloadAttachment(repository, 2, destinationFile, true); >- assertTrue(result); >- } >- >-// public void testAttachementUpload() throws Exception { >-// File sourceFile = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( >-// "testdata/contexts/downloadedContext.xml")); >-// TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL); >-// repository.setAuthenticationCredentials("relves@cs.ubc.ca", "***"); >-// boolean result = BugzillaRepositoryUtil.uploadAttachment(repository, 4, "Upload Comment 2", "Upload Description 2", sourceFile, "application/xml", false); >-// assertTrue(result); >-// } >- >-} >Index: src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestGMT.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestGMT.java >diff -N src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestGMT.java >--- src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestGMT.java 22 Feb 2006 04:50:44 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,219 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylar.bugzilla.tests; >- >-import java.io.File; >-import java.io.FileReader; >-import java.io.Reader; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Map; >- >-import junit.framework.TestCase; >- >-import org.eclipse.core.runtime.Path; >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.core.tests.support.FileTool; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >-import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; >- >-/** >- * Tests NewBugParser -- parses product attributes >- */ >-public class BugzillaNewBugParserTestGMT extends TestCase { >- >- public BugzillaNewBugParserTestGMT() { >- super(); >- } >- >- public BugzillaNewBugParserTestGMT(String arg0) { >- super(arg0); >- } >- >- public void testProductGMT() throws Exception { >- >- File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/gmt-page.html")); >- >- Reader in = new FileReader(f); >- >- NewBugModel nbm = new NewBugModel(); >- new NewBugParser(in).parseBugAttributes(nbm, true); // ** TRUE vs FALSE >- // ** >- >- // attributes for this bug model >- List<Attribute> attributes = nbm.getAttributes(); >- // printList(attributes); >- >- Iterator<Attribute> itr = attributes.iterator(); >- Attribute att = itr.next(); >- >- // Attribute: Severity >- assertEquals("Attribute: Severity", "Severity", att.getName()); >- >- Map<String, String> attOptions = att.getOptionValues(); // HashMap of >- // options for the >- // current >- // attribute >- Object[] options = attOptions.keySet().toArray(); // Array of keys for >- // the options of the >- // current attribute >- assertEquals("# Severity options", 7, options.length); >- >- int i = 0; >- while (i < options.length) { >- assertEquals("severity options", "blocker", options[i++]); >- assertEquals("severity options", "critical", options[i++]); >- assertEquals("severity options", "major", options[i++]); >- assertEquals("severity options", "normal", options[i++]); >- assertEquals("severity options", "minor", options[i++]); >- assertEquals("severity options", "trivial", options[i++]); >- assertEquals("severity options", "enhancement", options[i++]); >- } >- >- // Attribute: product >- att = itr.next(); >- assertEquals("Attribute: product", "product", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("No product options", 0, options.length); >- >- // Attribute: AssignedTo >- att = itr.next(); >- assertEquals("Attribute: AssignedTo", "AssignedTo", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("No AssignedTo options", 0, options.length); >- >- // Attribute: OS >- att = itr.next(); >- assertEquals("Attribute: OS", "OS", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("# of options", 20, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("OS options", "All", options[i++]); >- assertEquals("OS options", "AIX Motif", options[i++]); >- assertEquals("OS options", "Windows 95", options[i++]); >- assertEquals("OS options", "Windows 98", options[i++]); >- assertEquals("OS options", "Windows CE", options[i++]); >- assertEquals("OS options", "Windows ME", options[i++]); >- assertEquals("OS options", "Windows 2000", options[i++]); >- assertEquals("OS options", "Windows NT", options[i++]); >- assertEquals("OS options", "Windows XP", options[i++]); >- assertEquals("OS options", "Windows All", options[i++]); >- assertEquals("OS options", "MacOS X", options[i++]); >- assertEquals("OS options", "Linux", options[i++]); >- assertEquals("OS options", "Linux-GTK", options[i++]); >- assertEquals("OS options", "Linux-Motif", options[i++]); >- assertEquals("OS options", "HP-UX", options[i++]); >- assertEquals("OS options", "Neutrino", options[i++]); >- assertEquals("OS options", "QNX-Photon", options[i++]); >- assertEquals("OS options", "Solaris", options[i++]); >- assertEquals("OS options", "Unix All", options[i++]); >- assertEquals("OS options", "other", options[i++]); >- } >- >- // Attribute: Version >- att = itr.next(); >- assertEquals("Attribute: Version", "Version", att.getName()); >- >- // attOptions = (HashMap) att.getOptionValues(); >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# Version options", 1, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Version options", "unspecified", options[i++]); >- } >- >- // Attribute: Platform >- att = itr.next(); >- assertEquals("Attribute: Platform", "Platform", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# Platform options", 6, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Platform options", "All", options[i++]); >- assertEquals("Platform options", "Macintosh", options[i++]); >- assertEquals("Platform options", "PC", options[i++]); >- assertEquals("Platform options", "Power PC", options[i++]); >- assertEquals("Platform options", "Sun", options[i++]); >- assertEquals("Platform options", "Other", options[i++]); >- } >- >- att = itr.next(); >- assertEquals("Attribute: Component", "Component", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# Component options", 1, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Component options", "Core", options[i++]); >- } >- >- // Attribute: bug_status >- att = itr.next(); >- assertEquals("Attribute: bug_status", "bug_status", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No bug_status options", 0, options.length); >- >- // Attribute: form_name >- att = itr.next(); >- assertEquals("Attribute: form_name", "form_name", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No form_name options", 0, options.length); >- >- // Attribute: bug_file_loc >- att = itr.next(); >- assertEquals("Attribute: bug_file_loc", "bug_file_loc", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No bug_file_loc options", 0, options.length); >- >- // Attribute: priority >- att = itr.next(); >- assertEquals("Attribute: priority", "priority", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No priority options", 0, options.length); >- >- } >- >- // private void printList(List<Attribute> attributes) { >- // >- // Iterator<Attribute> itr = attributes.iterator(); >- // System.out.println("Attributes for this Product:"); >- // System.out.println("============================"); >- // >- // while (itr.hasNext()) { >- // Attribute attr = itr.next(); >- // System.out.println(); >- // System.out.println(attr.getName() + ": "); >- // System.out.println("-----------"); >- // >- // Map<String, String> options = attr.getOptionValues(); >- // Object[] it = options.keySet().toArray(); >- // for (int i = 0; i < it.length; i++) >- // System.out.println((String) it[i]); >- // } >- // } >-} >Index: src/org/eclipse/mylar/bugzilla/tests/BugzillaConfigurationTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.tests/src/org/eclipse/mylar/bugzilla/tests/BugzillaConfigurationTest.java,v >retrieving revision 1.2 >diff -u -r1.2 BugzillaConfigurationTest.java >--- src/org/eclipse/mylar/bugzilla/tests/BugzillaConfigurationTest.java 28 Apr 2006 23:42:25 -0000 1.2 >+++ src/org/eclipse/mylar/bugzilla/tests/BugzillaConfigurationTest.java 8 May 2006 23:07:30 -0000 >@@ -15,9 +15,11 @@ > > import junit.framework.TestCase; > >+import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; > import org.eclipse.mylar.internal.bugzilla.core.internal.RepositoryConfiguration; >-import org.eclipse.mylar.internal.bugzilla.core.internal.ServerConfigurationFactory; >+import org.eclipse.mylar.internal.bugzilla.core.internal.RepositoryConfigurationFactory; >+import org.eclipse.mylar.provisional.tasklist.TaskRepository; > > public class BugzillaConfigurationTest extends TestCase { > >@@ -31,8 +33,9 @@ > > > public void test222RDFProductConfig() throws IOException { >- ServerConfigurationFactory factory = ServerConfigurationFactory.getInstance(); >- RepositoryConfiguration config = factory.getConfiguration(IBugzillaConstants.TEST_BUGZILLA_222_URL); >+ RepositoryConfigurationFactory factory = RepositoryConfigurationFactory.getInstance(); >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL); >+ RepositoryConfiguration config = factory.getConfiguration(repository); > assertNotNull(config); > assertEquals("2.22rc1", config.getInstallVersion()); > assertEquals(7, config.getStatusValues().size()); >@@ -47,10 +50,11 @@ > assertEquals(1, config.getVersions("TestProduct").size()); > assertEquals(1, config.getTargetMilestones("TestProduct").size()); > } >- >+ > public void test2201RDFProductConfig() throws IOException { >- ServerConfigurationFactory factory = ServerConfigurationFactory.getInstance(); >- RepositoryConfiguration config = factory.getConfiguration(IBugzillaConstants.TEST_BUGZILLA_2201_URL); >+ RepositoryConfigurationFactory factory = RepositoryConfigurationFactory.getInstance(); >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_2201_URL); >+ RepositoryConfiguration config = factory.getConfiguration(repository); > assertNotNull(config); > assertEquals("2.20.1", config.getInstallVersion()); > assertEquals(7, config.getStatusValues().size()); >@@ -63,12 +67,13 @@ > assertEquals(4, config.getOpenStatusValues().size()); > assertEquals(2, config.getComponents("TestProduct").size()); > assertEquals(1, config.getVersions("TestProduct").size()); >- //assertEquals(1, config.getTargetMilestones("TestProduct").size()); >+ // assertEquals(1, config.getTargetMilestones("TestProduct").size()); > } > > public void test220RDFProductConfig() throws IOException { >- ServerConfigurationFactory factory = ServerConfigurationFactory.getInstance(); >- RepositoryConfiguration config = factory.getConfiguration(IBugzillaConstants.TEST_BUGZILLA_220_URL); >+ RepositoryConfigurationFactory factory = RepositoryConfigurationFactory.getInstance(); >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_220_URL); >+ RepositoryConfiguration config = factory.getConfiguration(repository); > assertNotNull(config); > assertEquals("2.20", config.getInstallVersion()); > assertEquals(7, config.getStatusValues().size()); >@@ -81,30 +86,32 @@ > assertEquals(4, config.getOpenStatusValues().size()); > assertEquals(2, config.getComponents("TestProduct").size()); > assertEquals(1, config.getVersions("TestProduct").size()); >- //assertEquals(1, config.getTargetMilestones("TestProduct").size()); >+ // assertEquals(1, config.getTargetMilestones("TestProduct").size()); > } > > public void test218RDFProductConfig() throws IOException { >- ServerConfigurationFactory factory = ServerConfigurationFactory.getInstance(); >- RepositoryConfiguration config = factory.getConfiguration(IBugzillaConstants.TEST_BUGZILLA_218_URL); >+ RepositoryConfigurationFactory factory = RepositoryConfigurationFactory.getInstance(); >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_218_URL); >+ RepositoryConfiguration config = factory.getConfiguration(repository); > assertNotNull(config); > assertEquals("2.18.5", config.getInstallVersion()); > assertEquals(7, config.getStatusValues().size()); > assertEquals(8, config.getResolutions().size()); > assertEquals(8, config.getPlatforms().size()); >- assertEquals(37, config.getOSs().size()); >+ assertEquals(36, config.getOSs().size()); > assertEquals(5, config.getPriorities().size()); > assertEquals(7, config.getSeverities().size()); > assertEquals(1, config.getProducts().size()); > assertEquals(4, config.getOpenStatusValues().size()); > assertEquals(1, config.getComponents("TestProduct").size()); > assertEquals(1, config.getVersions("TestProduct").size()); >- //assertEquals(1, config.getTargetMilestones("TestProduct").size()); >+ // assertEquals(1, config.getTargetMilestones("TestProduct").size()); > } > > public void testEclipseRDFProductConfig() throws IOException { >- ServerConfigurationFactory factory = ServerConfigurationFactory.getInstance(); >- RepositoryConfiguration config = factory.getConfiguration(IBugzillaConstants.ECLIPSE_BUGZILLA_URL); >+ RepositoryConfigurationFactory factory = RepositoryConfigurationFactory.getInstance(); >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.ECLIPSE_BUGZILLA_URL); >+ RepositoryConfiguration config = factory.getConfiguration(repository); > assertNotNull(config); > assertEquals("2.20.1", config.getInstallVersion()); > assertEquals(7, config.getStatusValues().size()); >@@ -113,10 +120,11 @@ > assertEquals(27, config.getOSs().size()); > assertEquals(5, config.getPriorities().size()); > assertEquals(7, config.getSeverities().size()); >- assertEquals(53, config.getProducts().size()); >+ assertEquals(52, config.getProducts().size()); > assertEquals(4, config.getOpenStatusValues().size()); > assertEquals(10, config.getComponents("Mylar").size()); >- //assertEquals(10, config.getComponents("Hyades").size()); >- //assertEquals(1, config.getTargetMilestones("TestProduct").size()); >+ assertEquals(21, config.getKeywords().size()); >+ // assertEquals(10, config.getComponents("Hyades").size()); >+ // assertEquals(1, config.getTargetMilestones("TestProduct").size()); > } > } >Index: src/org/eclipse/mylar/bugzilla/tests/AllBugzillaTests.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.tests/src/org/eclipse/mylar/bugzilla/tests/AllBugzillaTests.java,v >retrieving revision 1.13 >diff -u -r1.13 AllBugzillaTests.java >--- src/org/eclipse/mylar/bugzilla/tests/AllBugzillaTests.java 28 Apr 2006 20:41:41 -0000 1.13 >+++ src/org/eclipse/mylar/bugzilla/tests/AllBugzillaTests.java 8 May 2006 23:07:30 -0000 >@@ -21,21 +21,21 @@ > public static Test suite() { > TestSuite suite = new TestSuite("Test for org.eclipse.mylar.bugzilla.tests"); > // $JUnit-BEGIN$ >+ suite.addTestSuite(RepositoryReportFactoryTest.class); > suite.addTestSuite(BugzillaConfigurationTest.class); >- suite.addTestSuite(BugzillaTaskHyperlinkDetectorTest.class); >- suite.addTestSuite(ReportAttachmentTest.class); >+ suite.addTestSuite(BugzillaTaskHyperlinkDetectorTest.class); > suite.addTestSuite(BugzillaSearchEngineTest.class); >- suite.addTestSuite(Bugzilla220ParserTest.class); >+ //suite.addTestSuite(Bugzilla220ParserTest.class); > suite.addTestSuite(BugzillaRepositoryConnectorTest.class); > suite.addTestSuite(EncodingTest.class); >- suite.addTestSuite(NewBugWizardTest.class); >+ //suite.addTestSuite(NewBugWizardTest.class); > suite.addTestSuite(RegularExpressionMatchTest.class); > // suite.addTestSuite(BugzillaNewBugParserTestCDT.class); > // suite.addTestSuite(BugzillaNewBugParserTestEquinox.class); > // suite.addTestSuite(BugzillaNewBugParserTestGMT.class); > // suite.addTestSuite(BugzillaNewBugParserTestPlatform.class); > // suite.addTestSuite(BugzillaNewBugParserTestVE.class); >- suite.addTestSuite(BugzillaParserTestNoBug.class); >+ //suite.addTestSuite(BugzillaParserTestNoBug.class); > suite.addTestSuite(BugzillaProductParserTest.class); > // TODO: enable > // suite.addTest(new TestSuite(BugzillaParserTest.class)); >Index: src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestPlatform.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestPlatform.java >diff -N src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestPlatform.java >--- src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestPlatform.java 22 Feb 2006 04:50:44 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,246 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylar.bugzilla.tests; >- >-import java.io.File; >-import java.io.FileReader; >-import java.io.Reader; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Map; >- >-import junit.framework.TestCase; >- >-import org.eclipse.core.runtime.Path; >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.core.tests.support.FileTool; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >-import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; >- >-/** >- * Tests NewBugParser -- parses product attributes >- */ >-public class BugzillaNewBugParserTestPlatform extends TestCase { >- >- public BugzillaNewBugParserTestPlatform() { >- super(); >- } >- >- public BugzillaNewBugParserTestPlatform(String arg0) { >- super(arg0); >- } >- >- public void testProductPlatform() throws Exception { >- >- File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), >- new Path("testdata/pages/platform-page.html")); >- >- Reader in = new FileReader(f); >- >- NewBugModel nbm = new NewBugModel(); >- new NewBugParser(in).parseBugAttributes(nbm, true); // ** TRUE vs FALSE >- // ** >- >- // attributes for this bug model >- List<Attribute> attributes = nbm.getAttributes(); >- // printList(attributes); >- >- // to iterator over the ArrayList of attributes >- Iterator<Attribute> itr = attributes.iterator(); >- >- // Attribute: Severity >- Attribute att = itr.next(); // current attribute >- >- // Attribute: Severity >- assertEquals("Attribute: Severity", "Severity", att.getName()); >- >- Map<String, String> attOptions = att.getOptionValues(); // HashMap of >- // options for the >- // current >- // attribute >- Object[] options = attOptions.keySet().toArray(); // Array of keys for >- // the options of the >- // current attribute >- assertEquals("# Severity options", 7, options.length); >- >- int i = 0; >- while (i < options.length) { >- assertEquals("severity options", "blocker", options[i++]); >- assertEquals("severity options", "critical", options[i++]); >- assertEquals("severity options", "major", options[i++]); >- assertEquals("severity options", "normal", options[i++]); >- assertEquals("severity options", "minor", options[i++]); >- assertEquals("severity options", "trivial", options[i++]); >- assertEquals("severity options", "enhancement", options[i++]); >- } >- >- // Attribute: product >- att = itr.next(); >- assertEquals("Attribute: product", "product", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("No product optins", 0, options.length); >- >- // Attribute: AssignedTo >- att = itr.next(); >- assertEquals("Attribute: Assigned To", "Assigned To", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No AssingedTo options", 0, options.length); >- >- // Attribute: OS >- att = itr.next(); >- assertEquals("Attribute: OS", "OS", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("# OS options", 20, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("OS options", "All", options[i++]); >- assertEquals("OS options", "AIX Motif", options[i++]); >- assertEquals("OS options", "Windows 95", options[i++]); >- assertEquals("OS options", "Windows 98", options[i++]); >- assertEquals("OS options", "Windows CE", options[i++]); >- assertEquals("OS options", "Windows ME", options[i++]); >- assertEquals("OS options", "Windows 2000", options[i++]); >- assertEquals("OS options", "Windows NT", options[i++]); >- assertEquals("OS options", "Windows XP", options[i++]); >- assertEquals("OS options", "Windows All", options[i++]); >- assertEquals("OS options", "MacOS X", options[i++]); >- assertEquals("OS options", "Linux", options[i++]); >- assertEquals("OS options", "Linux-GTK", options[i++]); >- assertEquals("OS options", "Linux-Motif", options[i++]); >- assertEquals("OS options", "HP-UX", options[i++]); >- assertEquals("OS options", "Neutrino", options[i++]); >- assertEquals("OS options", "QNX-Photon", options[i++]); >- assertEquals("OS options", "Solaris", options[i++]); >- assertEquals("OS options", "Unix All", options[i++]); >- assertEquals("OS options", "other", options[i++]); >- } >- >- // Attribute: Version >- att = itr.next(); >- assertEquals("Attribute: Version", "Version", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("# Version options", 8, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Version options", "1.0", options[i++]); >- assertEquals("Version options", "2.0", options[i++]); >- assertEquals("Version options", "2.0.1", options[i++]); >- assertEquals("Version options", "2.0.2", options[i++]); >- assertEquals("Version options", "2.1", options[i++]); >- assertEquals("Version options", "2.1.1", options[i++]); >- assertEquals("Version options", "2.1.2", options[i++]); >- assertEquals("Version options", "3.0", options[i++]); >- } >- >- // Attribute: Platform >- att = itr.next(); >- assertEquals("Attribute: Platform", "Platform", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# Platform options", 6, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Platform options", "All", options[i++]); >- assertEquals("Platform options", "Macintosh", options[i++]); >- assertEquals("Platform options", "PC", options[i++]); >- assertEquals("Platform options", "Power PC", options[i++]); >- assertEquals("Platform options", "Sun", options[i++]); >- assertEquals("Platform options", "Other", options[i++]); >- } >- >- // Attribute: Component >- att = itr.next(); >- assertEquals("Attribute: Component", "Component", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("# Component options", 16, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Component options", "Ant", options[i++]); >- assertEquals("Component options", "Compare", options[i++]); >- assertEquals("Component options", "Core", options[i++]); >- assertEquals("Component options", "CVS", options[i++]); >- assertEquals("Component options", "Debug", options[i++]); >- assertEquals("Component options", "Doc", options[i++]); >- assertEquals("Component options", "Help", options[i++]); >- assertEquals("Component options", "Releng", options[i++]); >- assertEquals("Component options", "Scripting", options[i++]); >- assertEquals("Component options", "Search", options[i++]); >- assertEquals("Component options", "SWT", options[i++]); >- assertEquals("Component options", "Team", options[i++]); >- assertEquals("Component options", "Text", options[i++]); >- assertEquals("Component options", "UI", options[i++]); >- assertEquals("Component options", "Update", options[i++]); >- assertEquals("Component options", "WebDAV", options[i++]); >- } >- >- // Attribute: bug_status >- att = itr.next(); >- assertEquals("Attribute: bug_status", "bug_status", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("No bug_status options", 0, options.length); >- >- // Attribute: form_name >- att = itr.next(); >- assertEquals("Attribute: form_name", "form_name", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No form_name options", 0, options.length); >- >- // Attribute: bug_file_loc >- att = itr.next(); >- assertEquals("Attribute: bug_file_loc", "bug_file_loc", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No bug_file_loc options", 0, options.length); >- >- // Attribute: priority >- att = itr.next(); >- assertEquals("Attribute: priority", "priority", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No priority options", 0, options.length); >- } >- >- // private void printList(List<Attribute> attributes) { >- // >- // Iterator<Attribute> itr = attributes.iterator(); >- // System.out.println("Attributes for this Product:"); >- // System.out.println("============================"); >- // >- // while (itr.hasNext()) { >- // Attribute attr = itr.next(); >- // System.out.println(); >- // System.out.println(attr.getName() + ": "); >- // System.out.println("-----------"); >- // >- // Map<String, String> options = attr.getOptionValues(); >- // Object[] it = options.keySet().toArray(); >- // for (int i = 0; i < it.length; i++) >- // System.out.println((String) it[i]); >- // } >- // } >-} >Index: src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestVE.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestVE.java >diff -N src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestVE.java >--- src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestVE.java 22 Feb 2006 04:50:44 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,225 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylar.bugzilla.tests; >- >-import java.io.File; >-import java.io.FileReader; >-import java.io.Reader; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Map; >- >-import junit.framework.TestCase; >- >-import org.eclipse.core.runtime.Path; >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.core.tests.support.FileTool; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >-import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; >- >-/** >- * Tests NewBugParser -- parses product attributes >- */ >-public class BugzillaNewBugParserTestVE extends TestCase { >- >- public BugzillaNewBugParserTestVE() { >- super(); >- } >- >- public BugzillaNewBugParserTestVE(String arg0) { >- super(arg0); >- } >- >- public void testProductVE() throws Exception { >- File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/ve-page.html")); >- >- Reader in = new FileReader(f); >- >- NewBugModel nbm = new NewBugModel(); >- new NewBugParser(in).parseBugAttributes(nbm, true); // ** TRUE vs FALSE >- // ** >- >- // attributes for this but model >- List<Attribute> attributes = nbm.getAttributes(); >- // printList(attributes); >- >- Iterator<Attribute> itr = attributes.iterator(); >- Attribute att = itr.next(); >- >- // Attribute: Severity >- assertEquals("Attribute: Severity", "Severity", att.getName()); >- >- Map<String, String> attOptions = att.getOptionValues(); // HashMap of >- // options for the >- // current >- // attribute >- Object[] options = attOptions.keySet().toArray(); // Array of keys for >- // the options of the >- // current attribute >- assertEquals("# Severity options", 7, options.length); >- >- int i = 0; >- while (i < options.length) { >- assertEquals("severity options", "blocker", options[i++]); >- assertEquals("severity options", "critical", options[i++]); >- assertEquals("severity options", "major", options[i++]); >- assertEquals("severity options", "normal", options[i++]); >- assertEquals("severity options", "minor", options[i++]); >- assertEquals("severity options", "trivial", options[i++]); >- assertEquals("severity options", "enhancement", options[i++]); >- } >- >- // Attribute: product >- att = itr.next(); >- assertEquals("Attribute: product", "product", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("No product options", 0, options.length); >- >- // Attribute: AssignedTo >- att = itr.next(); >- assertEquals("Attribute: AssignedTo", "AssignedTo", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("No AssignedTo options", 0, options.length); >- >- // Attribute: OS >- att = itr.next(); >- assertEquals("Attribute: OS", "OS", att.getName()); >- >- attOptions = att.getOptionValues(); >- options = attOptions.keySet().toArray(); >- assertEquals("# of options", 20, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("OS options", "All", options[i++]); >- assertEquals("OS options", "AIX Motif", options[i++]); >- assertEquals("OS options", "Windows 95", options[i++]); >- assertEquals("OS options", "Windows 98", options[i++]); >- assertEquals("OS options", "Windows CE", options[i++]); >- assertEquals("OS options", "Windows ME", options[i++]); >- assertEquals("OS options", "Windows 2000", options[i++]); >- assertEquals("OS options", "Windows NT", options[i++]); >- assertEquals("OS options", "Windows XP", options[i++]); >- assertEquals("OS options", "Windows All", options[i++]); >- assertEquals("OS options", "MacOS X", options[i++]); >- assertEquals("OS options", "Linux", options[i++]); >- assertEquals("OS options", "Linux-GTK", options[i++]); >- assertEquals("OS options", "Linux-Motif", options[i++]); >- assertEquals("OS options", "HP-UX", options[i++]); >- assertEquals("OS options", "Neutrino", options[i++]); >- assertEquals("OS options", "QNX-Photon", options[i++]); >- assertEquals("OS options", "Solaris", options[i++]); >- assertEquals("OS options", "Unix All", options[i++]); >- assertEquals("OS options", "other", options[i++]); >- } >- >- // Attribute: Version >- att = itr.next(); >- assertEquals("Attribute: Version", "Version", att.getName()); >- >- // attOptions = (HashMap) att.getOptionValues(); >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# Version options", 3, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Version options", "0.5.0", options[i++]); >- assertEquals("Version options", "1.0.0", options[i++]); >- assertEquals("Version options", "unspecified", options[i++]); >- } >- >- // Attribute: Platform >- att = itr.next(); >- assertEquals("Attribute: Platform", "Platform", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# Platform options", 6, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Platform options", "All", options[i++]); >- assertEquals("Platform options", "Macintosh", options[i++]); >- assertEquals("Platform options", "PC", options[i++]); >- assertEquals("Platform options", "Power PC", options[i++]); >- assertEquals("Platform options", "Sun", options[i++]); >- assertEquals("Platform options", "Other", options[i++]); >- } >- >- att = itr.next(); >- assertEquals("Attribute: Component", "Component", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# Component options", 6, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Component options", "CDE", options[i++]); >- assertEquals("Component options", "Doc", options[i++]); >- assertEquals("Component options", "Java Core", options[i++]); >- assertEquals("Component options", "Java Model (JEM)", options[i++]); >- assertEquals("Component options", "JFC/Swing", options[i++]); >- assertEquals("Component options", "SWT", options[i++]); >- } >- >- // Attribute: bug_status >- att = itr.next(); >- assertEquals("Attribute: bug_status", "bug_status", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No bug_status options", 0, options.length); >- >- // Attribute: form_name >- att = itr.next(); >- assertEquals("Attribute: form_name", "form_name", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No form_name options", 0, options.length); >- >- // Attribute: bug_file_loc >- att = itr.next(); >- assertEquals("Attribute: bug_file_loc", "bug_file_loc", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No bug_file_loc options", 0, options.length); >- >- // Attribute: priority >- att = itr.next(); >- assertEquals("Attribute: priority", "priority", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No priority options", 0, options.length); >- >- } >- >- // private void printList(List<Attribute> attributes) { >- // >- // Iterator<Attribute> itr = attributes.iterator(); >- // System.out.println("Attributes for this Product:"); >- // System.out.println("============================"); >- // >- // while (itr.hasNext()) { >- // Attribute attr = itr.next(); >- // System.out.println(); >- // System.out.println(attr.getName() + ": "); >- // System.out.println("-----------"); >- // >- // Map<String, String> options = attr.getOptionValues(); >- // Object[] it = options.keySet().toArray(); >- // for (int i = 0; i < it.length; i++) >- // System.out.println((String) it[i]); >- // } >- // } >-} >Index: src/org/eclipse/mylar/bugzilla/tests/BugzillaParserTestNoBug.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/tests/BugzillaParserTestNoBug.java >diff -N src/org/eclipse/mylar/bugzilla/tests/BugzillaParserTestNoBug.java >--- src/org/eclipse/mylar/bugzilla/tests/BugzillaParserTestNoBug.java 22 Feb 2006 04:50:44 -0000 1.6 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,47 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2003 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.mylar.bugzilla.tests; >- >-import java.io.File; >-import java.io.FileReader; >-import java.io.Reader; >- >-import junit.framework.TestCase; >- >-import org.eclipse.core.runtime.Path; >-import org.eclipse.mylar.bugzilla.core.BugReport; >-import org.eclipse.mylar.core.tests.support.FileTool; >-import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser; >- >-/** >- * Tests for parsing Bugzilla reports >- */ >-public class BugzillaParserTestNoBug extends TestCase { >- >- public BugzillaParserTestNoBug() { >- super(); >- } >- >- public BugzillaParserTestNoBug(String arg0) { >- super(arg0); >- } >- >- public void testBugNotFound() throws Exception { >- >- File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( >- "testdata/pages/bug-not-found-eclipse.html")); >- >- Reader in = new FileReader(f); >- >- BugReport bug = BugParser.parseBug(in, 666, "<server>", false, null, null, null); >- assertNull(bug); >- } >-} >Index: src/org/eclipse/mylar/bugzilla/tests/NewBugWizardTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.tests/src/org/eclipse/mylar/bugzilla/tests/NewBugWizardTest.java,v >retrieving revision 1.9 >diff -u -r1.9 NewBugWizardTest.java >--- src/org/eclipse/mylar/bugzilla/tests/NewBugWizardTest.java 13 Mar 2006 23:56:43 -0000 1.9 >+++ src/org/eclipse/mylar/bugzilla/tests/NewBugWizardTest.java 8 May 2006 23:07:30 -0000 >@@ -11,19 +11,16 @@ > > package org.eclipse.mylar.bugzilla.tests; > >-import java.io.File; >-import java.io.FileReader; >-import java.io.Reader; >- > import junit.framework.TestCase; > >-import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Platform; >-import org.eclipse.mylar.bugzilla.core.BugReport; >-import org.eclipse.mylar.core.tests.support.FileTool; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >-import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; >+import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; >+import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; >+import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; > import org.eclipse.mylar.internal.bugzilla.ui.wizard.AbstractBugzillaWizardPage; >+import org.eclipse.mylar.provisional.tasklist.TaskRepository; > import org.eclipse.ui.PlatformUI; > > /** >@@ -34,44 +31,43 @@ > > public void testPlatformOptions() throws Exception { > >- File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/cdt-page.html")); >- Reader in = new FileReader(f); >- >- NewBugModel model = new NewBugModel(); >+ NewBugzillaReport newReport = new NewBugzillaReport(IBugzillaConstants.TEST_BUGZILLA_220_URL); > AbstractBugzillaWizardPage page = new TestWizardDataPage(); >- new NewBugParser(in).parseBugAttributes(model, true); // ** TRUE vs >- // FALSE ** >- page.setPlatformOptions(model); >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, >+ IBugzillaConstants.TEST_BUGZILLA_220_URL); >+ BugzillaRepositoryUtil.setupNewBugAttributes(repository, newReport); // FALSE >+ // ** >+ page.setPlatformOptions(newReport); > > String os = Platform.getOS(); > if (os.equals("win32")) >- assertEquals("Windows All", model.getAttribute(BugReport.ATTRIBUTE_OS).getValue()); >+ assertEquals("Windows", newReport.getAttribute(BugzillaReportElement.OP_SYS).getValue()); > else if (os.equals("solaris")) >- assertEquals("Solaris", model.getAttribute(BugReport.ATTRIBUTE_OS).getValue()); >+ assertEquals("Solaris", newReport.getAttribute(BugzillaReportElement.OP_SYS).getValue()); > else if (os.equals("qnx")) >- assertEquals("QNX-Photon", model.getAttribute(BugReport.ATTRIBUTE_OS).getValue()); >+ assertEquals("QNX-Photon", newReport.getAttribute(BugzillaReportElement.OP_SYS).getValue()); > else if (os.equals("macosx")) >- assertEquals("MacOS X", model.getAttribute(BugReport.ATTRIBUTE_OS).getValue()); >+ assertEquals("Mac OS", newReport.getAttribute(BugzillaReportElement.OP_SYS).getValue()); > else if (os.equals("linux")) >- assertEquals("Linux", model.getAttribute(BugReport.ATTRIBUTE_OS).getValue()); >+ assertEquals("Linux", newReport.getAttribute(BugzillaReportElement.OP_SYS).getValue()); > else if (os.equals("hpux")) >- assertEquals("HP-UX", model.getAttribute(BugReport.ATTRIBUTE_OS).getValue()); >+ assertEquals("HP-UX", newReport.getAttribute(BugzillaReportElement.OP_SYS).getValue()); > else if (os.equals("aix")) >- assertEquals("AIX", model.getAttribute(BugReport.ATTRIBUTE_OS).getValue()); >+ assertEquals("AIX", newReport.getAttribute(BugzillaReportElement.OP_SYS).getValue()); > > String platform = Platform.getOSArch(); > if (platform.equals("x86")) >- assertEquals("PC", model.getAttribute(BugReport.ATTRIBUTE_PLATFORM).getValue()); >+ assertEquals("PC", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM).getValue()); > else if (platform.equals("x86_64")) >- assertEquals("PC", model.getAttribute(BugReport.ATTRIBUTE_PLATFORM).getValue()); >+ assertEquals("PC", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM).getValue()); > else if (platform.equals("ia64")) >- assertEquals("PC", model.getAttribute(BugReport.ATTRIBUTE_PLATFORM).getValue()); >+ assertEquals("PC", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM).getValue()); > else if (platform.equals("ia64_32")) >- assertEquals("PC", model.getAttribute(BugReport.ATTRIBUTE_PLATFORM).getValue()); >+ assertEquals("PC", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM).getValue()); > else if (platform.equals("sparc")) >- assertEquals("Sun", model.getAttribute(BugReport.ATTRIBUTE_PLATFORM).getValue()); >+ assertEquals("Sun", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM).getValue()); > else if (platform.equals("ppc")) >- assertEquals("Power", model.getAttribute(BugReport.ATTRIBUTE_PLATFORM).getValue()); >+ assertEquals("Power", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM).getValue()); > > } > >Index: src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestEquinox.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestEquinox.java >diff -N src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestEquinox.java >--- src/org/eclipse/mylar/bugzilla/tests/BugzillaNewBugParserTestEquinox.java 22 Feb 2006 04:50:44 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,219 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylar.bugzilla.tests; >- >-import java.io.File; >-import java.io.FileReader; >-import java.io.Reader; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Map; >- >-import junit.framework.TestCase; >- >-import org.eclipse.core.runtime.Path; >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.core.tests.support.FileTool; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >-import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; >- >-/** >- * Tests NewBugParser -- parses product attributes >- */ >-public class BugzillaNewBugParserTestEquinox extends TestCase { >- >- public BugzillaNewBugParserTestEquinox() { >- super(); >- } >- >- public BugzillaNewBugParserTestEquinox(String arg0) { >- super(arg0); >- } >- >- public void testProductEquinox() throws Exception { >- >- File f = FileTool >- .getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/equinox-page.html")); >- >- Reader in = new FileReader(f); >- >- NewBugModel nbm = new NewBugModel(); >- new NewBugParser(in).parseBugAttributes(nbm, true); // ** TRUE vs FALSE >- // ** >- >- // attributes for this bug model >- List<Attribute> attributes = nbm.getAttributes(); >- // printList(attributes); >- >- Iterator<Attribute> itr = attributes.iterator(); >- Attribute att = itr.next(); >- >- // Attribute: Severity >- assertEquals("Attribute: Severity", "Severity", att.getName()); >- >- Map<String, String> attOptions = att.getOptionValues(); // HashMap of >- // options for the >- // current >- // attribute >- Object[] options = attOptions.keySet().toArray(); // Array of keys for >- // the options of the >- // current attribute >- assertEquals("# Severity options", 7, options.length); >- >- int i = 0; >- while (i < options.length) { >- assertEquals("severity options", "blocker", options[i++]); >- assertEquals("severity options", "critical", options[i++]); >- assertEquals("severity options", "major", options[i++]); >- assertEquals("severity options", "normal", options[i++]); >- assertEquals("severity options", "minor", options[i++]); >- assertEquals("severity options", "trivial", options[i++]); >- assertEquals("severity options", "enhancement", options[i++]); >- } >- >- // Attribute: product >- att = itr.next(); >- assertEquals("Attribute: prodcut", "product", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No product options", 0, options.length); >- >- // Attribute: AssignedTo >- att = itr.next(); >- assertEquals("Attribute: AssignedTo", "AssignedTo", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No AssignedTo options", 0, options.length); >- >- // Attribute: OS >- att = itr.next(); >- assertEquals("Attribute: OS", "OS", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# OS options", 20, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("OS options", "All", options[i++]); >- assertEquals("OS options", "AIX Motif", options[i++]); >- assertEquals("OS options", "Windows 95", options[i++]); >- assertEquals("OS options", "Windows 98", options[i++]); >- assertEquals("OS options", "Windows CE", options[i++]); >- assertEquals("OS options", "Windows ME", options[i++]); >- assertEquals("OS options", "Windows 2000", options[i++]); >- assertEquals("OS options", "Windows NT", options[i++]); >- assertEquals("OS options", "Windows XP", options[i++]); >- assertEquals("OS options", "Windows All", options[i++]); >- assertEquals("OS options", "MacOS X", options[i++]); >- assertEquals("OS options", "Linux", options[i++]); >- assertEquals("OS options", "Linux-GTK", options[i++]); >- assertEquals("OS options", "Linux-Motif", options[i++]); >- assertEquals("OS options", "HP-UX", options[i++]); >- assertEquals("OS options", "Neutrino", options[i++]); >- assertEquals("OS options", "QNX-Photon", options[i++]); >- assertEquals("OS options", "Solaris", options[i++]); >- assertEquals("OS options", "Unix All", options[i++]); >- assertEquals("OS options", "other", options[i++]); >- } >- >- // Attribute: Version >- att = itr.next(); >- assertEquals("Attribute: Version", "Version", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# Version options", 1, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Version options", "unspecified", options[i++]); >- } >- >- // Attribute: Platform >- att = itr.next(); >- assertEquals("Attribute: Platform", "Platform", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# Platform options", 6, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Platform options", "All", options[i++]); >- assertEquals("Platform options", "Macintosh", options[i++]); >- assertEquals("Platform options", "PC", options[i++]); >- assertEquals("Platform options", "Power PC", options[i++]); >- assertEquals("Platform options", "Sun", options[i++]); >- assertEquals("Platform options", "Other", options[i++]); >- } >- >- // Attribute: Component >- att = itr.next(); >- assertEquals("Attribute: Component", "Component", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("# Component options", 3, options.length); >- >- i = 0; >- while (i < options.length) { >- assertEquals("Component options", "Dynamic Plugins", options[i++]); >- assertEquals("Component options", "General", options[i++]); >- assertEquals("Component options", "OSGi", options[i++]); >- } >- >- // Attribute: bug_status >- att = itr.next(); >- assertEquals("Attribute: bug_status", "bug_status", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No bug_status options", 0, options.length); >- >- // Attribute: form_name >- att = itr.next(); >- assertEquals("Attribute: form_name", "form_name", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No form_name options", 0, options.length); >- >- // Attribute: bug_file_loc >- att = itr.next(); >- assertEquals("Attribute: bug_file_loc", "bug_file_loc", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No bug_file_loc options", 0, options.length); >- >- // Attribute: priority >- att = itr.next(); >- assertEquals("Attribute: priority", "priority", att.getName()); >- >- options = att.getOptionValues().keySet().toArray(); >- assertEquals("No priority options", 0, options.length); >- >- } >- >- // private void printList(List<Attribute> attributes) { >- // >- // Iterator<Attribute> itr = attributes.iterator(); >- // System.out.println("Attributes for this Product:"); >- // System.out.println("============================"); >- // >- // while (itr.hasNext()) { >- // Attribute attr = itr.next(); >- // System.out.println(); >- // System.out.println(attr.getName() + ": "); >- // System.out.println("-----------"); >- // >- // Map<String, String> options = attr.getOptionValues(); >- // Object[] it = options.keySet().toArray(); >- // for (int i = 0; i < it.length; i++) >- // System.out.println((String) it[i]); >- // } >- // } >-} >Index: src/org/eclipse/mylar/bugzilla/tests/EncodingTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.tests/src/org/eclipse/mylar/bugzilla/tests/EncodingTest.java,v >retrieving revision 1.3 >diff -u -r1.3 EncodingTest.java >--- src/org/eclipse/mylar/bugzilla/tests/EncodingTest.java 24 Jan 2006 19:46:48 -0000 1.3 >+++ src/org/eclipse/mylar/bugzilla/tests/EncodingTest.java 8 May 2006 23:07:30 -0000 >@@ -18,7 +18,7 @@ > > import junit.framework.TestCase; > >-import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser; >+import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; > > /** > * @author Mik Kersten >@@ -27,17 +27,17 @@ > > public void testEncodingSetting() throws LoginException, IOException, ParseException { > >- String charset = BugParser.getCharsetFromString("text/html; charset=UTF-8"); >+ String charset = BugzillaRepositoryUtil.getCharsetFromString("text/html; charset=UTF-8"); > assertEquals("UTF-8", charset); > >- charset = BugParser.getCharsetFromString("text/html"); >+ charset = BugzillaRepositoryUtil.getCharsetFromString("text/html"); > assertEquals(null, charset); > >- charset = BugParser >+ charset = BugzillaRepositoryUtil > .getCharsetFromString("<<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-2\">>"); > assertEquals("iso-8859-2", charset); > >- charset = BugParser.getCharsetFromString("<<meta http-equiv=\"Content-Type\" content=\"text/html\">>"); >+ charset = BugzillaRepositoryUtil.getCharsetFromString("<<meta http-equiv=\"Content-Type\" content=\"text/html\">>"); > assertEquals(null, charset); > } > >Index: src/org/eclipse/mylar/bugzilla/tests/BugzillaSearchEngineTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.tests/src/org/eclipse/mylar/bugzilla/tests/BugzillaSearchEngineTest.java,v >retrieving revision 1.5 >diff -u -r1.5 BugzillaSearchEngineTest.java >--- src/org/eclipse/mylar/bugzilla/tests/BugzillaSearchEngineTest.java 28 Apr 2006 23:42:25 -0000 1.5 >+++ src/org/eclipse/mylar/bugzilla/tests/BugzillaSearchEngineTest.java 8 May 2006 23:07:30 -0000 >@@ -22,9 +22,9 @@ > import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >-import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaRepositoryConnector; > import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaRepositoryQuery; > import org.eclipse.mylar.provisional.tasklist.AbstractQueryHit; >+import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector; > import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin; > import org.eclipse.mylar.provisional.tasklist.TaskRepository; > >@@ -99,7 +99,7 @@ > QUERY_NAME, > MAX_HITS, MylarTaskListPlugin.getTaskListManager().getTaskList()); > >- BugzillaRepositoryConnector connector = (BugzillaRepositoryConnector) MylarTaskListPlugin.getRepositoryManager().getRepositoryConnector(BugzillaPlugin.REPOSITORY_KIND); >+ AbstractRepositoryConnector connector = (AbstractRepositoryConnector) MylarTaskListPlugin.getRepositoryManager().getRepositoryConnector(BugzillaPlugin.REPOSITORY_KIND); > results.addAll(connector.performQuery(repositoryQuery, new NullProgressMonitor(), new MultiStatus(MylarTaskListPlugin.PLUGIN_ID, IStatus.OK, "Query result", null))); > return results; > } >Index: src/org/eclipse/mylar/bugzilla/tests/BugzillaParserTest.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/tests/BugzillaParserTest.java >diff -N src/org/eclipse/mylar/bugzilla/tests/BugzillaParserTest.java >--- src/org/eclipse/mylar/bugzilla/tests/BugzillaParserTest.java 22 Feb 2006 04:50:44 -0000 1.6 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,196 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2003 - 2006 University Of British Columbia and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * University Of British Columbia - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.mylar.bugzilla.tests; >- >-import java.io.File; >-import java.io.FileReader; >-import java.io.Reader; >-import java.util.Iterator; >- >-import junit.framework.TestCase; >- >-import org.eclipse.core.runtime.Path; >-import org.eclipse.mylar.bugzilla.core.BugReport; >-import org.eclipse.mylar.bugzilla.core.Comment; >-import org.eclipse.mylar.core.tests.support.FileTool; >-import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser; >- >-/** >- * Tests for parsing Bugzilla reports >- */ >-public class BugzillaParserTest extends TestCase { >- >- public BugzillaParserTest() { >- super(); >- } >- >- public BugzillaParserTest(String arg0) { >- super(arg0); >- } >- >- public void testFullReportBug1() throws Exception { >- >- File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/bug-1-full.html")); >- >- Reader in = new FileReader(f); >- >- BugReport bug = BugParser.parseBug(in, 1, "<server>", false, null, null, null); >- >- // displayBug(bug); >- assertEquals("Bug id", 1, bug.getId()); >- assertEquals("Bug summary", "Usability issue with external editors (1GE6IRL)", bug.getSummary()); >- assertEquals("Reporter", "andre_weinand@ch.ibm.com (Andre Weinand)", bug.getReporter()); >- assertEquals("Reporter", "andre_weinand@ch.ibm.com (Andre Weinand)", bug.getAttribute("Reporter").getValue()); >- assertEquals("Summary", "Usability issue with external editors (1GE6IRL)", bug.getSummary()); >- assertEquals("Status", "VERIFIED", bug.getStatus()); >- assertEquals("Resolution", "FIXED", bug.getResolution()); >- assertEquals("Keywords", null, bug.getKeywords()); >- assertEquals("Assigned To", "James_Moody@ca.ibm.com (James Moody)", bug.getAssignedTo()); >- assertEquals("Priority", "P3", bug.getAttribute("Priority").getValue()); >- assertEquals("OS", "All", bug.getAttribute("OS").getValue()); >- assertEquals("Version", "2.0", bug.getAttribute("Version").getValue()); >- assertEquals("Target Milestone", "---", bug.getAttribute("Target Milestone").getValue()); >- assertEquals("Keywords", "", bug.getAttribute("Keywords").getValue()); >- assertEquals("Severity", "normal", bug.getAttribute("Severity").getValue()); >- assertEquals("Component", "VCM", bug.getAttribute("Component").getValue()); >- assertEquals("CC", "Kevin_McGuire@oti.com", bug.getCC().iterator().next()); >- assertEquals("Platform", "All", bug.getAttribute("Platform").getValue()); >- assertEquals("Product", "Platform", bug.getAttribute("Product").getValue()); >- assertEquals("URL", "", bug.getAttribute("URL").getValue()); >- assertEquals("Bug#", "1", bug.getAttribute("Bug#").getValue()); >- >- // Description >- String description = "- Setup a project that contains a *.gif resource\n" >- + "\t- release project to CVS\n" >- + "\t- edit the *.gif resource with an external editor, e.g. PaintShop\n" >- + "\t- save and close external editor\n" >- + "\t- in Navigator open the icon resource and verify that your changes are there\n" >- + "\t- release project\n" >- + "\t\t-> nothing to release!\n" >- + "\t- in Navigator open the icon resource and verify that your changes are still there\n\n" >- + >- >- "\tProblem: because I never \"Refreshed from local\", the workspace hasn't changed so \"Release\" didn't find anything.\n" >- + "\tHowever opening the resource with an external editor found the modified file on disk and showed the changes.\n\n" >- + >- >- "\tThe real problem occurs if \"Release\" actually finds something to release but you don't spot that some resources are missing.\n" >- + "\tThis is extremely error prone: one of my changes didn't made it into build 110 because of this!\n\n" >- + >- >- "NOTES:\n" >- + "EG (5/23/01 3:00:33 PM)\n" >- + "\tRelease should do a refresh from local before doing the release.\n" >- + "\tMoving to VCM\n\n\n" >- + >- >- "KM (05/27/01 5:10:19 PM)\n" >- + "\tComments from JM in related email:\n\n" >- + >- >- "\tShould not do this for free. Could have a setting which made it optoinal but should nt be mandatory. Default setting could be to have it on.\n" >- + "\tConsider the SWT team who keep their workspaces on network drives. This will be slow. \n\n" >- + >- >- "\tSide effects will be that a build runs when the refresh is completed unless you somehow do it in a workspace runnable and don't end the\n" >- + "\trunnable until after the release. This would be less than optimal as some builders may be responsible for maintaining some invariants and deriving resources which are releasable. If you don't run the builders before releasing, the invariants will not be maintained and you will release inconsistent state.\n\n" >- + >- >- "\tSummary: Offer to \"ensure local consistency\" before releasing.\n\n" + >- >- "KM (5/31/01 1:30:35 PM)\n" >- + "\tSee also 1GEAG1A: ITPVCM:WINNT - Internal error comparing with a document\n" >- + "\twhich failed with an error. Never got log from Tod though."; >- >- assert (description.length() == bug.getDescription().length()); >- assertEquals("Description", description, bug.getDescription()); >- >- // Comments: >- Iterator<Comment> it = bug.getComments().iterator(); >- while (it.hasNext()) { >- // COMMENT #1 >- Comment comment = it.next(); >- assertEquals("Author1", "James_Moody@ca.ibm.com", comment.getAuthor()); >- assertEquals("Name1", "James Moody", comment.getAuthorName()); >- assertEquals("Text1", "*** Bug 183 has been marked as a duplicate of this bug. ***", comment.getText()); >- >- // COMMENT #2 >- comment = it.next(); >- assertEquals("Author2", "James_Moody@ca.ibm.com", comment.getAuthor()); >- assertEquals("Name2", "James Moody", comment.getAuthorName()); >- assertEquals("Text2", "Implemented 'auto refresh' option. Default value is off.", comment.getText()); >- >- // COMMENT 3 >- comment = it.next(); >- assertEquals("Author3", "dj_houghton@ca.ibm.com", comment.getAuthor()); >- assertEquals("Name3", "DJ Houghton", comment.getAuthorName()); >- assertEquals("Text3", "PRODUCT VERSION:\n\t109\n\n", comment.getText()); >- >- // COMMENT 4 >- comment = it.next(); >- assertEquals("Author4", "James_Moody@ca.ibm.com", comment.getAuthor()); >- assertEquals("Name4", "James Moody", comment.getAuthorName()); >- assertEquals("Text4", "Fixed in v206", comment.getText()); >- } >- } >- >- // private static void displayBug(BugReport bug) { >- // System.out.println("Bug " + bug.getId() + ": " + bug.getSummary()); >- // System.out.println("Opened: " + bug.getCreated()); >- // for (Iterator<Attribute> it = bug.getAttributes().iterator(); >- // it.hasNext();) { >- // Attribute attribute = it.next(); >- // String key = attribute.getName(); >- // System.out.println(key + ": " + attribute.getValue() >- // + (attribute.isEditable() ? " [OK]" : " %%")); >- // } >- // >- // System.out.print("CC: "); >- // for (Iterator<String> it = bug.getCC().iterator(); it.hasNext();) { >- // String email = it.next(); >- // System.out.print(email + " "); >- // } >- // System.out.println(); >- // >- // System.out.println(bug.getDescription()); >- // for (Iterator<Comment> it = bug.getComments().iterator(); it.hasNext();) >- // { >- // Comment comment = it.next(); >- // System.out.println(comment.getAuthorName() + " <" >- // + comment.getAuthor() + "> (" + comment.getCreated() + ")"); >- // System.out.print(comment.getText()); >- // System.out.println(); >- // } >- // } >- // >- // private static void printComments(BugReport bug) { >- // for (Iterator<Comment> it = bug.getComments().iterator(); it.hasNext();) >- // { >- // Comment comment = it.next(); >- // System.out.println("Author: " + comment.getAuthor()); >- // System.out.println("Name: " + comment.getAuthorName()); >- // System.out.println("Date: " + comment.getCreated()); >- // System.out.println("Bug ID: " + comment.getBug().getId()); >- // System.out.println("Comment: " + comment.getText()); >- // System.out.println(); >- // } >- // } >- // >- // /** prints names of attributes */ >- // private static void printAttributes(BugReport bug) { >- // System.out.println("ATTRIBUTE KEYS:"); >- // for (Iterator<Attribute> it = bug.getAttributes().iterator(); >- // it.hasNext();) { >- // Attribute att = it.next(); >- // System.out.println(att.getName()); >- // } >- // } >-} >Index: src/org/eclipse/mylar/bugzilla/tests/BugzillaRepositoryConnectorTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.tests/src/org/eclipse/mylar/bugzilla/tests/BugzillaRepositoryConnectorTest.java,v >retrieving revision 1.8 >diff -u -r1.8 BugzillaRepositoryConnectorTest.java >--- src/org/eclipse/mylar/bugzilla/tests/BugzillaRepositoryConnectorTest.java 13 Mar 2006 21:19:19 -0000 1.8 >+++ src/org/eclipse/mylar/bugzilla/tests/BugzillaRepositoryConnectorTest.java 8 May 2006 23:07:30 -0000 >@@ -13,17 +13,16 @@ > > import java.net.MalformedURLException; > import java.util.Date; >-import java.util.Iterator; > > import javax.security.auth.login.LoginException; > > import junit.framework.TestCase; > >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaException; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportSubmitForm; >+import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; > import org.eclipse.mylar.internal.bugzilla.core.PossibleBugzillaFailureException; > import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaQueryHit; > import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaRepositoryConnector; >@@ -45,7 +44,7 @@ > > private static final String DEFAULT_KIND = BugzillaPlugin.REPOSITORY_KIND; > >- private static final String TEST_REPOSITORY_URL = "https://bugs.eclipse.org/bugs"; >+ //private static final String TEST_REPOSITORY_URL = "https://bugs.eclipse.org/bugs"; > > private BugzillaRepositoryConnector client; > >@@ -60,7 +59,7 @@ > super.setUp(); > manager = MylarTaskListPlugin.getRepositoryManager(); > manager.clearRepositories(); >- repository = new TaskRepository(DEFAULT_KIND, TEST_REPOSITORY_URL); >+ repository = new TaskRepository(DEFAULT_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL); > // repository.setAuthenticationCredentials("userid", "password"); > manager.addRepository(repository); > assertNotNull(manager); >@@ -113,10 +112,11 @@ > > // Modify it > String newCommentText = "BugzillaRepositoryClientTest.testSynchronize(): " + (new Date()).toString(); >- task.getBugReport().setNewNewComment(newCommentText); >+ task.getBugReport().setNewComment(newCommentText); > // overwrites old fields/attributes with new content (ususually done by > // BugEditor) >- updateBug(task.getBugReport()); >+ task.getBugReport().setHasChanged(true); >+// updateBug(task.getBugReport()); > assertEquals(task.getSyncState(), RepositoryTaskSyncState.SYNCHRONIZED); > client.saveBugReport(task.getBugReport()); > assertEquals(RepositoryTaskSyncState.OUTGOING, task.getSyncState()); >@@ -155,7 +155,7 @@ > // because task doesn't have bug report (new query hit) > // Result: retrieved with no incoming status > task.setSyncState(RepositoryTaskSyncState.SYNCHRONIZED); >- BugReport bugReport = task.getBugReport(); >+ BugzillaReport bugReport = task.getBugReport(); > task.setBugReport(null); > client.synchronize(task, false, null); > assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState()); >@@ -186,24 +186,24 @@ > > } > >- protected void updateBug(BugReport bug) { >+ protected void updateBug(BugzillaReport bug) { > > // go through all of the attributes and update the main values to the > // new ones >- for (Iterator<Attribute> it = bug.getAttributes().iterator(); it.hasNext();) { >- Attribute attribute = it.next(); >- if (attribute.getNewValue() != null && attribute.getNewValue().compareTo(attribute.getValue()) != 0) { >- bug.setHasChanged(true); >- } >- attribute.setValue(attribute.getNewValue()); >- >- } >- if (bug.getNewComment().compareTo(bug.getNewNewComment()) != 0) { >- bug.setHasChanged(true); >- } >+// for (Iterator<AbstractRepositoryReportAttribute> it = bug.getAttributes().iterator(); it.hasNext();) { >+// AbstractRepositoryReportAttribute attribute = it.next(); >+// if (attribute.getValue() != null && attribute.getValue().compareTo(attribute.getValue()) != 0) { >+// bug.setHasChanged(true); >+// } >+// attribute.setValue(attribute.getNewValue()); >+// >+// } >+// if (bug.getNewComment().compareTo(bug.getNewNewComment()) != 0) { >+// bug.setHasChanged(true); >+// } > > // Update some other fields as well. >- bug.setNewComment(bug.getNewNewComment()); >+ //bug.setNewComment(bug.getNewNewComment()); > > } > >Index: src/org/eclipse/mylar/bugzilla/tests/RepositoryReportFactoryTest.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/tests/RepositoryReportFactoryTest.java >diff -N src/org/eclipse/mylar/bugzilla/tests/RepositoryReportFactoryTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/bugzilla/tests/RepositoryReportFactoryTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,310 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.tests; >+ >+import java.io.IOException; >+ >+import javax.security.auth.login.LoginException; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; >+import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; >+import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; >+import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; >+import org.eclipse.mylar.internal.bugzilla.core.internal.RepositoryReportFactory; >+import org.eclipse.mylar.provisional.tasklist.TaskRepository; >+ >+public class RepositoryReportFactoryTest extends TestCase { >+ >+ RepositoryReportFactory factory = RepositoryReportFactory.getInstance(); >+ >+ public void testBugNoFound222() { >+ int bugid = -1; >+ String errorMessage = ""; >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, >+ IBugzillaConstants.TEST_BUGZILLA_222_URL); >+ try { >+ BugzillaReport report = new BugzillaReport(bugid, repository.getUrl()); >+ factory.populateReport(report, repository); >+ } catch (LoginException e) { >+ // >+ } catch (IOException e) { >+ errorMessage = e.getMessage(); >+ } >+ assertEquals(IBugzillaConstants.ERROR_INVALID_BUG_ID, errorMessage); >+ } >+ >+ public void testInvalidCredentials222() { >+ int bugid = 1; >+ String errorMessage = ""; >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, >+ IBugzillaConstants.TEST_BUGZILLA_222_URL); >+ repository.setAuthenticationCredentials("invalid", "invalid"); >+ try { >+ BugzillaReport report = new BugzillaReport(bugid, repository.getUrl()); >+ factory.populateReport(report, repository); >+ } catch (LoginException e) { >+ errorMessage = e.getMessage(); >+ } catch (IOException e) { >+ errorMessage = e.getMessage(); >+ } >+ assertEquals(IBugzillaConstants.ERROR_INVALID_USERNAME_OR_PASSWORD, errorMessage); >+ repository.flushAuthenticationCredentials(); >+ } >+ >+ public void testReadingReport() throws Exception { >+ int bugid = 4; >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, >+ IBugzillaConstants.TEST_BUGZILLA_222_URL); >+ >+ BugzillaReport report = new BugzillaReport(bugid, repository.getUrl()); >+ BugzillaRepositoryUtil.setupExistingBugAttributes(repository.getUrl(), report); >+ factory.populateReport(report, repository); >+ >+ assertNotNull(report); >+ assertEquals("Another Test", report.getAttribute(BugzillaReportElement.SHORT_DESC).getValue()); >+ assertEquals("TestProduct", report.getAttribute(BugzillaReportElement.PRODUCT).getValue()); >+ assertEquals("PC", report.getAttribute(BugzillaReportElement.REP_PLATFORM).getValue()); >+ assertEquals("Other", report.getAttribute(BugzillaReportElement.OP_SYS).getValue()); >+ assertEquals(37, report.getComments().size()); >+ assertEquals("Testing new 2.22 version capability", report.getComments().get(0).getAttribute( >+ BugzillaReportElement.THETEXT).getValue()); >+ assertEquals(15, report.getAttachments().size()); >+ assertEquals("1", report.getAttachments().get(0).getAttribute(BugzillaReportElement.ATTACHID).getValue()); >+ assertEquals("2006-03-10 14:11", report.getAttachments().get(0).getAttribute(BugzillaReportElement.DATE) >+ .getValue()); >+ assertEquals("Testing upload", report.getAttachments().get(0).getAttribute(BugzillaReportElement.DESC) >+ .getValue()); >+ assertEquals("patch130217.txt", report.getAttachments().get(0).getAttribute(BugzillaReportElement.FILENAME) >+ .getValue()); >+ assertEquals("text/plain", report.getAttachments().get(0).getAttribute(BugzillaReportElement.TYPE).getValue()); >+ } >+ >+ public void testReadingReport222() throws Exception { >+ int bugid = 1; >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, >+ IBugzillaConstants.TEST_BUGZILLA_222_URL); >+ >+ BugzillaReport report = new BugzillaReport(bugid, repository.getUrl()); >+ BugzillaRepositoryUtil.setupExistingBugAttributes(repository.getUrl(), report); >+ factory.populateReport(report, repository); >+ >+ assertNotNull(report); >+ assertEquals("search-match-test 1", report.getAttribute(BugzillaReportElement.SHORT_DESC).getValue()); >+ assertEquals("TestProduct", report.getAttribute(BugzillaReportElement.PRODUCT).getValue()); >+ assertEquals("TestComponent", report.getAttribute(BugzillaReportElement.COMPONENT).getValue()); >+ assertEquals("PC", report.getAttribute(BugzillaReportElement.REP_PLATFORM).getValue()); >+ assertEquals("Windows", report.getAttribute(BugzillaReportElement.OP_SYS).getValue()); >+ assertEquals("other", report.getAttribute(BugzillaReportElement.VERSION).getValue()); >+ assertEquals("P1", report.getAttribute(BugzillaReportElement.PRIORITY).getValue()); >+ assertEquals("blocker", report.getAttribute(BugzillaReportElement.BUG_SEVERITY).getValue()); >+ assertEquals("1", report.getAttribute(BugzillaReportElement.BUG_ID).getValue()); >+ assertEquals("NEW", report.getAttribute(BugzillaReportElement.BUG_STATUS).getValue()); >+ assertEquals("2006-03-08 19:59", report.getAttribute(BugzillaReportElement.CREATION_TS).getValue()); >+ assertEquals("2006-03-08 19:59:15", report.getAttribute(BugzillaReportElement.DELTA_TS).getValue()); >+ assertEquals("---", report.getAttribute(BugzillaReportElement.TARGET_MILESTONE).getValue()); >+ assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.REPORTER).getValue()); >+ assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.ASSIGNED_TO).getValue()); >+ assertEquals(1, report.getComments().size()); >+ assertEquals("relves@cs.ubc.ca", report.getComments().get(0).getAttribute(BugzillaReportElement.WHO).getValue()); >+ assertEquals("2006-03-08 19:59:15", report.getComments().get(0).getAttribute(BugzillaReportElement.BUG_WHEN) >+ .getValue()); >+ assertEquals("search-match-test 1", report.getComments().get(0).getAttribute(BugzillaReportElement.THETEXT) >+ .getValue()); >+ assertEquals(0, report.getAttachments().size()); >+ } >+ >+ public void testReadingReport2201() throws Exception { >+ int bugid = 1; >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, >+ IBugzillaConstants.TEST_BUGZILLA_2201_URL); >+ >+ BugzillaReport report = new BugzillaReport(bugid, repository.getUrl()); >+ BugzillaRepositoryUtil.setupExistingBugAttributes(repository.getUrl(), report); >+ factory.populateReport(report, repository); >+ >+ assertNotNull(report); >+ assertEquals("1", report.getAttribute(BugzillaReportElement.BUG_ID).getValue()); >+ assertEquals("search-match-test 1", report.getAttribute(BugzillaReportElement.SHORT_DESC).getValue()); >+ assertEquals("TestProduct", report.getAttribute(BugzillaReportElement.PRODUCT).getValue()); >+ assertEquals("TestComponent", report.getAttribute(BugzillaReportElement.COMPONENT).getValue()); >+ assertEquals("PC", report.getAttribute(BugzillaReportElement.REP_PLATFORM).getValue()); >+ assertEquals("Windows", report.getAttribute(BugzillaReportElement.OP_SYS).getValue()); >+ assertEquals("other", report.getAttribute(BugzillaReportElement.VERSION).getValue()); >+ assertEquals("P2", report.getAttribute(BugzillaReportElement.PRIORITY).getValue()); >+ assertEquals("normal", report.getAttribute(BugzillaReportElement.BUG_SEVERITY).getValue()); >+ assertEquals("NEW", report.getAttribute(BugzillaReportElement.BUG_STATUS).getValue()); >+ assertEquals("2006-03-02 18:13", report.getAttribute(BugzillaReportElement.CREATION_TS).getValue()); >+ assertEquals("2006-05-03 13:06:11", report.getAttribute(BugzillaReportElement.DELTA_TS).getValue()); >+ assertEquals("---", report.getAttribute(BugzillaReportElement.TARGET_MILESTONE).getValue()); >+ AbstractRepositoryReportAttribute attribute = report.getAttribute(BugzillaReportElement.BLOCKED); >+ assertEquals(2, attribute.getValues().size()); >+ assertEquals("2", attribute.getValues().get(0)); >+ assertEquals("9", attribute.getValues().get(1)); >+ attribute = report.getAttribute(BugzillaReportElement.CC); >+ assertEquals(2, attribute.getValues().size()); >+ assertEquals("relves@cs.ubc.ca", attribute.getValues().get(0)); >+ assertEquals("relves@gmail.com", attribute.getValues().get(1)); >+ assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.REPORTER).getValue()); >+ assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.ASSIGNED_TO).getValue()); >+ assertEquals(1, report.getComments().size()); >+ assertEquals("relves@cs.ubc.ca", report.getComments().get(0).getAttribute(BugzillaReportElement.WHO).getValue()); >+ assertEquals("2006-03-02 18:13", report.getComments().get(0).getAttribute(BugzillaReportElement.BUG_WHEN) >+ .getValue()); >+ assertEquals("search-match-test 1", report.getComments().get(0).getAttribute(BugzillaReportElement.THETEXT) >+ .getValue()); >+ assertEquals(0, report.getAttachments().size()); >+ } >+ >+ public void testReadingReport2201Eclipse() throws Exception { >+ int bugid = 24448; >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, >+ IBugzillaConstants.ECLIPSE_BUGZILLA_URL); >+ >+ BugzillaReport report = new BugzillaReport(bugid, repository.getUrl()); >+ BugzillaRepositoryUtil.setupExistingBugAttributes(repository.getUrl(), report); >+ factory.populateReport(report, repository); >+ >+ assertNotNull(report); >+ assertEquals("24448", report.getAttribute(BugzillaReportElement.BUG_ID).getValue()); >+ assertEquals("Ant causing Out of Memory", report.getAttribute(BugzillaReportElement.SHORT_DESC).getValue()); >+ assertEquals("Platform", report.getAttribute(BugzillaReportElement.PRODUCT).getValue()); >+ assertEquals("Ant", report.getAttribute(BugzillaReportElement.COMPONENT).getValue()); >+ assertEquals("PC", report.getAttribute(BugzillaReportElement.REP_PLATFORM).getValue()); >+ assertEquals("other", report.getAttribute(BugzillaReportElement.OP_SYS).getValue()); >+ assertEquals("2.0", report.getAttribute(BugzillaReportElement.VERSION).getValue()); >+ assertEquals("P2", report.getAttribute(BugzillaReportElement.PRIORITY).getValue()); >+ assertEquals("normal", report.getAttribute(BugzillaReportElement.BUG_SEVERITY).getValue()); >+ assertEquals("RESOLVED", report.getAttribute(BugzillaReportElement.BUG_STATUS).getValue()); >+ assertEquals("WONTFIX", report.getAttribute(BugzillaReportElement.RESOLUTION).getValue()); >+ assertEquals("2002-10-07 09:32", report.getAttribute(BugzillaReportElement.CREATION_TS).getValue()); >+ assertEquals("2006-02-03 12:03:57", report.getAttribute(BugzillaReportElement.DELTA_TS).getValue()); >+ assertEquals("core, performance, ui", report.getAttribute(BugzillaReportElement.KEYWORDS).getValue()); >+ // AbstractRepositoryReportAttribute attribute = >+ // report.getAttribute(BugzillaReportElement.CC); >+ // assertEquals(30, attribute.getValues().size()); >+ // assertEquals("relves@cs.ubc.ca", attribute.getValues().get(0)); >+ // assertEquals("relves@gmail.com", attribute.getValues().get(1)); >+ // assertEquals("relves@cs.ubc.ca", >+ // report.getAttribute(BugzillaReportElement.REPORTER).getValue()); >+ // assertEquals("relves@cs.ubc.ca", >+ // report.getAttribute(BugzillaReportElement.ASSIGNED_TO).getValue()); >+ // assertEquals(1, report.getComments().size()); >+ // assertEquals("relves@cs.ubc.ca", >+ // report.getComments().get(0).getAttribute(BugzillaReportElement.WHO).getValue()); >+ // assertEquals("2006-03-02 18:13", >+ // report.getComments().get(0).getAttribute(BugzillaReportElement.BUG_WHEN) >+ // .getValue()); >+ // assertEquals("search-match-test 1", >+ // report.getComments().get(0).getAttribute(BugzillaReportElement.THETEXT) >+ // .getValue()); >+ // assertEquals(0, report.getAttachments().size()); >+ } >+ >+ public void testReadingReport220() throws Exception { >+ int bugid = 1; >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, >+ IBugzillaConstants.TEST_BUGZILLA_220_URL); >+ >+ BugzillaReport report = new BugzillaReport(bugid, repository.getUrl()); >+ BugzillaRepositoryUtil.setupExistingBugAttributes(repository.getUrl(), report); >+ factory.populateReport(report, repository); >+ >+ assertNotNull(report); >+ assertEquals("1", report.getAttribute(BugzillaReportElement.BUG_ID).getValue()); >+ assertEquals("search-match-test", report.getAttribute(BugzillaReportElement.SHORT_DESC).getValue()); >+ assertEquals("TestProduct", report.getAttribute(BugzillaReportElement.PRODUCT).getValue()); >+ assertEquals("TestComponent", report.getAttribute(BugzillaReportElement.COMPONENT).getValue()); >+ assertEquals("PC", report.getAttribute(BugzillaReportElement.REP_PLATFORM).getValue()); >+ assertEquals("Windows", report.getAttribute(BugzillaReportElement.OP_SYS).getValue()); >+ assertEquals("other", report.getAttribute(BugzillaReportElement.VERSION).getValue()); >+ assertEquals("P2", report.getAttribute(BugzillaReportElement.PRIORITY).getValue()); >+ assertEquals("normal", report.getAttribute(BugzillaReportElement.BUG_SEVERITY).getValue()); >+ assertEquals("NEW", report.getAttribute(BugzillaReportElement.BUG_STATUS).getValue()); >+ assertEquals("2006-03-02 17:30", report.getAttribute(BugzillaReportElement.CREATION_TS).getValue()); >+ assertEquals("2006-04-20 15:13:43", report.getAttribute(BugzillaReportElement.DELTA_TS).getValue()); >+ assertEquals("---", report.getAttribute(BugzillaReportElement.TARGET_MILESTONE).getValue()); >+ assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.REPORTER).getValue()); >+ assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.ASSIGNED_TO).getValue()); >+ assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.CC).getValue()); >+ assertEquals(3, report.getComments().size()); >+ assertEquals("relves@cs.ubc.ca", report.getComments().get(0).getAttribute(BugzillaReportElement.WHO).getValue()); >+ assertEquals("2006-03-02 17:30", report.getComments().get(0).getAttribute(BugzillaReportElement.BUG_WHEN) >+ .getValue()); >+ assertEquals("search-match-test", report.getComments().get(0).getAttribute(BugzillaReportElement.THETEXT) >+ .getValue()); >+ assertEquals(0, report.getAttachments().size()); >+ } >+ >+ public void testReadingReport218() throws Exception { >+ int bugid = 1; >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, >+ IBugzillaConstants.TEST_BUGZILLA_218_URL); >+ >+ BugzillaReport report = new BugzillaReport(bugid, repository.getUrl()); >+ BugzillaRepositoryUtil.setupExistingBugAttributes(repository.getUrl(), report); >+ factory.populateReport(report, repository); >+ >+ assertNotNull(report); >+ assertEquals("1", report.getAttribute(BugzillaReportElement.BUG_ID).getValue()); >+ assertEquals("search-match-test 1", report.getAttribute(BugzillaReportElement.SHORT_DESC).getValue()); >+ assertEquals("TestProduct", report.getAttribute(BugzillaReportElement.PRODUCT).getValue()); >+ assertEquals("TestComponent", report.getAttribute(BugzillaReportElement.COMPONENT).getValue()); >+ assertEquals("PC", report.getAttribute(BugzillaReportElement.REP_PLATFORM).getValue()); >+ assertEquals("Windows XP", report.getAttribute(BugzillaReportElement.OP_SYS).getValue()); >+ assertEquals("other", report.getAttribute(BugzillaReportElement.VERSION).getValue()); >+ assertEquals("P2", report.getAttribute(BugzillaReportElement.PRIORITY).getValue()); >+ assertEquals("normal", report.getAttribute(BugzillaReportElement.BUG_SEVERITY).getValue()); >+ assertEquals("NEW", report.getAttribute(BugzillaReportElement.BUG_STATUS).getValue()); >+ assertEquals("2006-03-02 18:09", report.getAttribute(BugzillaReportElement.CREATION_TS).getValue()); >+ assertEquals("2006-05-05 17:45:24", report.getAttribute(BugzillaReportElement.DELTA_TS).getValue()); >+ assertEquals("---", report.getAttribute(BugzillaReportElement.TARGET_MILESTONE).getValue()); >+ assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.REPORTER).getValue()); >+ assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.ASSIGNED_TO).getValue()); >+ assertEquals(1, report.getComments().size()); >+ assertEquals("relves@cs.ubc.ca", report.getComments().get(0).getAttribute(BugzillaReportElement.WHO).getValue()); >+ assertEquals("2006-03-02 18:09", report.getComments().get(0).getAttribute(BugzillaReportElement.BUG_WHEN) >+ .getValue()); >+ assertEquals("search-match-test 1", report.getComments().get(0).getAttribute(BugzillaReportElement.THETEXT) >+ .getValue()); >+ assertEquals(0, report.getAttachments().size()); >+ } >+ >+ public void testBugReportAPI() throws Exception { >+ int bugid = 4; >+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, >+ IBugzillaConstants.TEST_BUGZILLA_222_URL); >+ >+ BugzillaReport report = new BugzillaReport(bugid, repository.getUrl()); >+ BugzillaRepositoryUtil.setupExistingBugAttributes(repository.getUrl(), report); >+ factory.populateReport(report, repository); >+ >+ assertNotNull(report); >+ assertTrue(report instanceof BugzillaReport); >+ BugzillaReport bugReport = (BugzillaReport) report; >+ assertEquals("Another Test", bugReport.getSummary()); >+ assertEquals("Testing new 2.22 version capability", bugReport.getDescription()); >+ assertEquals("TestProduct", bugReport.getProduct()); >+ assertEquals("relves@cs.ubc.ca", bugReport.getAssignedTo()); >+ // assertEquals("Other", >+ // report.getAttribute(BugzillaReportElement.OP_SYS).getValue()); >+ // assertEquals(37, report.getComments().size()); >+ // assertEquals("Testing new 2.22 version capability", >+ // report.getComments().get(0).getAttribute(BugzillaReportElement.THETEXT).getValue()); >+ // assertEquals(15, report.getAttachments().size()); >+ // assertEquals("1", >+ // report.getAttachments().get(0).getAttribute(BugzillaReportElement.ATTACHID).getValue()); >+ } >+} >#P org.eclipse.mylar.bugzilla.ui >Index: src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaReportNode.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaReportNode.java,v >retrieving revision 1.1 >diff -u -r1.1 BugzillaReportNode.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaReportNode.java 24 Jan 2006 19:55:13 -0000 1.1 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaReportNode.java 8 May 2006 23:07:32 -0000 >@@ -18,7 +18,7 @@ > > import javax.security.auth.login.LoginException; > >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; > import org.eclipse.mylar.internal.bugzilla.core.search.BugzillaSearchHit; > >@@ -43,7 +43,7 @@ > private List<StackTrace> stackTraces; > > /** The bug report associated with this DoiInfo */ >- private BugReport bug; >+ private BugzillaReport bug; > > /** > * Constructor >@@ -107,7 +107,7 @@ > * @throws LoginException > * @throws MalformedURLException > */ >- public BugReport getBug() throws MalformedURLException, LoginException, IOException { >+ public BugzillaReport getBug() throws MalformedURLException, LoginException, IOException { > if (bug == null) { > // get the bug report > bug = BugzillaRepositoryUtil.getBug(hit.getRepository(), hit.getId()); >@@ -121,7 +121,7 @@ > * @param bug - > * BugReport that this is associated with > */ >- public void setBug(BugReport bug) { >+ public void setBug(BugzillaReport bug) { > this.bug = bug; > } > >Index: src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaTask.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaTask.java,v >retrieving revision 1.28 >diff -u -r1.28 BugzillaTask.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaTask.java 28 Apr 2006 22:02:31 -0000 1.28 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaTask.java 8 May 2006 23:07:32 -0000 >@@ -16,11 +16,12 @@ > import java.util.Date; > import java.util.List; > >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.bugzilla.core.Comment; > import org.eclipse.mylar.bugzilla.core.IBugzillaBug; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; > import org.eclipse.mylar.internal.bugzilla.core.internal.HtmlStreamTokenizer; > import org.eclipse.mylar.internal.bugzilla.core.internal.OfflineReportsFile; > import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryTask; >@@ -34,7 +35,7 @@ > * The bug report for this BugzillaTask. This is <code>null</code> if the > * bug report with the specified ID was unable to download. > */ >- protected transient BugReport bugReport = null; >+ protected transient BugzillaReport bugReport = null; > > public BugzillaTask(String handle, String label, boolean newTask) { > super(handle, label, newTask); >@@ -70,7 +71,7 @@ > bugReport = null; > return true; > } >- bugReport = (BugReport) tempBug; >+ bugReport = (BugzillaReport) tempBug; > > if (bugReport.hasChanges()) > syncState = RepositoryTaskSyncState.OUTGOING; >@@ -90,13 +91,13 @@ > } > } > >- public BugReport getBugReport() { >+ public BugzillaReport getBugReport() { > return bugReport; > } > > public String getTaskType() { >- if (bugReport != null && bugReport.getAttribute(BugReport.ATTRIBUTE_SEVERITY) != null) { >- return bugReport.getAttribute(BugReport.ATTRIBUTE_SEVERITY).getValue(); >+ if (bugReport != null && bugReport.getAttribute(BugzillaReportElement.BUG_SEVERITY) != null) { >+ return bugReport.getAttribute(BugzillaReportElement.BUG_SEVERITY).getValue(); > } else { > return null; > } >@@ -106,7 +107,7 @@ > * @param bugReport > * The bugReport to set. > */ >- public void setBugReport(BugReport bugReport) { >+ public void setBugReport(BugzillaReport bugReport) { > this.bugReport = bugReport; > > // TODO: remove? >@@ -162,8 +163,8 @@ > > @Override > public String getPriority() { >- if (bugReport != null && bugReport.getAttribute(BugReport.ATTR_PRIORITY) != null) { >- return bugReport.getAttribute(BugReport.ATTR_PRIORITY).getValue(); >+ if (bugReport != null && bugReport.getAttribute(BugzillaReportElement.PRIORITY) != null) { >+ return bugReport.getAttribute(BugzillaReportElement.PRIORITY).getValue(); > } else { > return super.getPriority(); > } >Index: src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaCacheFile.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaCacheFile.java,v >retrieving revision 1.1 >diff -u -r1.1 BugzillaCacheFile.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaCacheFile.java 24 Jan 2006 19:55:13 -0000 1.1 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaCacheFile.java 8 May 2006 23:07:32 -0000 >@@ -21,7 +21,7 @@ > import java.util.List; > > import org.eclipse.jface.dialogs.MessageDialog; >-import org.eclipse.mylar.bugzilla.core.IBugzillaBug; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; > > /** >@@ -35,7 +35,7 @@ > > private File file; > >- private ArrayList<IBugzillaBug> list = new ArrayList<IBugzillaBug>(); >+ private ArrayList<BugzillaReport> list = new ArrayList<BugzillaReport>(); > > protected int latestNewBugId = 0; > >@@ -46,7 +46,7 @@ > } > } > >- public void add(IBugzillaBug entry) { >+ public void add(BugzillaReport entry) { > // add the entry to the list and write the file to disk > list.add(entry); > writeFile(); >@@ -63,14 +63,14 @@ > > public int find(int id) { > for (int i = 0; i < list.size(); i++) { >- IBugzillaBug currBug = list.get(i); >+ BugzillaReport currBug = list.get(i); > if (currBug != null && (currBug.getId() == id) && !currBug.isLocallyCreated()) > return i; > } > return -1; > } > >- public ArrayList<IBugzillaBug> elements() { >+ public ArrayList<BugzillaReport> elements() { > return list; > } > >@@ -108,14 +108,14 @@ > > // read in each of the offline reports in the file > for (int nX = 0; nX < size; nX++) { >- IBugzillaBug item = (IBugzillaBug) in.readObject(); >+ BugzillaReport item = (BugzillaReport) in.readObject(); > // add the offline report to the offlineReports list > list.add(item); > } > in.close(); > } > >- public void remove(List<IBugzillaBug> sel) { >+ public void remove(List<BugzillaReport> sel) { > list.removeAll(sel); > > // rewrite the file so that the data is persistant >Index: src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaRepositoryConnector.java,v >retrieving revision 1.29 >diff -u -r1.29 BugzillaRepositoryConnector.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaRepositoryConnector.java 28 Apr 2006 23:42:29 -0000 1.29 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaRepositoryConnector.java 8 May 2006 23:07:32 -0000 >@@ -34,10 +34,10 @@ > import org.eclipse.jface.window.ApplicationWindow; > import org.eclipse.jface.wizard.IWizard; > import org.eclipse.jface.wizard.WizardDialog; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.bugzilla.core.BugzillaRemoteContextDelegate; >-import org.eclipse.mylar.bugzilla.core.Comment; >-import org.eclipse.mylar.bugzilla.core.IBugzillaBug; >+import org.eclipse.mylar.bugzilla.core.ReportAttachment; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaException; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportSubmitForm; >@@ -147,12 +147,12 @@ > return BugzillaPlugin.REPOSITORY_KIND; > } > >- public void saveBugReport(IBugzillaBug bugzillaBug) { >+ public void saveBugReport(BugzillaReport bugzillaBug) { > String handle = AbstractRepositoryTask.getHandle(bugzillaBug.getRepositoryUrl(), bugzillaBug.getId()); > ITask task = MylarTaskListPlugin.getTaskListManager().getTaskList().getTask(handle); > if (task instanceof BugzillaTask) { > BugzillaTask bugzillaTask = (BugzillaTask) task; >- bugzillaTask.setBugReport((BugReport) bugzillaBug); >+ bugzillaTask.setBugReport((BugzillaReport) bugzillaBug); > > if (bugzillaBug.hasChanges()) { > bugzillaTask.setSyncState(RepositoryTaskSyncState.OUTGOING); >@@ -164,7 +164,7 @@ > > } > >- private BugReport downloadReport(final BugzillaTask bugzillaTask) { >+ private BugzillaReport downloadReport(final BugzillaTask bugzillaTask) { > try { > return BugzillaRepositoryUtil.getBug(bugzillaTask.getRepositoryUrl(), AbstractRepositoryTask > .getTaskIdAsInt(bugzillaTask.getHandleIdentifier())); >@@ -325,7 +325,8 @@ > } > } > >- private static void offlineStatusChange(IBugzillaBug bug, BugzillaOfflineStatus status, boolean forceSynch) { >+ private static void offlineStatusChange(AbstractRepositoryReport report, BugzillaOfflineStatus status, >+ boolean forceSynch) { > > RepositoryTaskSyncState state = null; > if (status == BugzillaOfflineStatus.SAVED_WITH_OUTGOING_CHANGES) { >@@ -350,7 +351,7 @@ > return; > } > >- String handle = AbstractRepositoryTask.getHandle(bug.getRepositoryUrl(), bug.getId()); >+ String handle = AbstractRepositoryTask.getHandle(report.getRepositoryUrl(), report.getId()); > ITask task = MylarTaskListPlugin.getTaskListManager().getTaskList().getTask(handle); > if (task != null && task instanceof BugzillaTask) { > BugzillaTask bugTask = (BugzillaTask) task; >@@ -359,7 +360,7 @@ > } > } > >- public void submitBugReport(final IBugzillaBug bugReport, final BugzillaReportSubmitForm form, >+ public void submitBugReport(final BugzillaReport bugReport, final BugzillaReportSubmitForm form, > IJobChangeListener listener) { > > if (forceSyncExecForTesting) { >@@ -412,7 +413,7 @@ > } > } > >- private void internalSubmitBugReport(IBugzillaBug bugReport, BugzillaReportSubmitForm form) { >+ private void internalSubmitBugReport(BugzillaReport bugReport, BugzillaReportSubmitForm form) { > try { > form.submitReportToRepository(); > removeReport(bugReport); >@@ -420,9 +421,12 @@ > // TODO: avoid getting archive tasks? > ITask task = MylarTaskListPlugin.getTaskListManager().getTaskList().getTask(handle); > >- Set<AbstractRepositoryQuery> queriesWithHandle = MylarTaskListPlugin.getTaskListManager().getTaskList() >- .getQueriesForHandle(task.getHandleIdentifier()); >- synchronize(queriesWithHandle, null, Job.INTERACTIVE, 0); >+ // TODO: re-enable synchronization of queries with task. Redundant? >+ // Set<AbstractRepositoryQuery> queriesWithHandle = >+ // MylarTaskListPlugin.getTaskListManager().getTaskList() >+ // .getQueriesForHandle(task.getHandleIdentifier()); >+ // synchronize(queriesWithHandle, null, Job.INTERACTIVE, 0); >+ > // for (AbstractRepositoryQuery query : queriesWithHandle) { > // synchronize(query, null); > // } >@@ -444,7 +448,7 @@ > * @param saveChosen > * This is used to determine a refresh from a user save > */ >- public BugzillaOfflineStatus saveOffline(final IBugzillaBug bug, final boolean forceSynch) { >+ public BugzillaOfflineStatus saveOffline(final BugzillaReport bug, final boolean forceSynch) { > > BugzillaOfflineStatus status = BugzillaOfflineStatus.ERROR; > >@@ -460,9 +464,10 @@ > return status; > } > >- private void internalSaveOffline(final IBugzillaBug bug, final boolean forceSynch) { >+ // TODO: pull up >+ private void internalSaveOffline(final BugzillaReport report, final boolean forceSynch) { > // If there is already an offline report for this bug, update the file. >- if (bug.isSavedOffline()) { >+ if (((AbstractRepositoryReport) report).isSavedOffline()) { > offlineReportsFile.update(); > } else { > try { >@@ -479,10 +484,10 @@ > // // identical id."); > // // return; > // } >- BugzillaOfflineStatus offlineStatus = offlineReportsFile.add(bug, false); >- bug.setOfflineState(true); >+ BugzillaOfflineStatus offlineStatus = offlineReportsFile.add(report, false); >+ ((AbstractRepositoryReport) report).setOfflineState(true); > // saveForced forced to false (hack) >- offlineStatusChange(bug, offlineStatus, forceSynch); >+ offlineStatusChange(report, offlineStatus, forceSynch); > > } catch (CoreException e) { > MylarStatusHandler.fail(e, e.getMessage(), false); >@@ -491,15 +496,15 @@ > } > } > >- public static List<IBugzillaBug> getOfflineBugs() { >+ public static List<BugzillaReport> getOfflineBugs() { > OfflineReportsFile file = BugzillaPlugin.getDefault().getOfflineReports(); > return file.elements(); > } > >- public static void removeReport(IBugzillaBug bug) { >+ public static void removeReport(BugzillaReport bug) { > bug.setOfflineState(false); > offlineStatusChange(bug, BugzillaOfflineStatus.DELETED, false); >- ArrayList<IBugzillaBug> bugList = new ArrayList<IBugzillaBug>(); >+ ArrayList<BugzillaReport> bugList = new ArrayList<BugzillaReport>(); > bugList.add(bug); > BugzillaPlugin.getDefault().getOfflineReports().remove(bugList); > } >@@ -574,7 +579,7 @@ > protected void updateOfflineState(AbstractRepositoryTask repositoryTask, boolean forceSync) { > if (repositoryTask instanceof BugzillaTask) { > BugzillaTask bugzillaTask = (BugzillaTask) repositoryTask; >- BugReport downloadedReport = downloadReport(bugzillaTask); >+ BugzillaReport downloadedReport = downloadReport(bugzillaTask); > if (downloadedReport != null) { > bugzillaTask.setBugReport(downloadedReport); > saveOffline(downloadedReport, forceSync); >@@ -649,11 +654,20 @@ > if (task instanceof BugzillaTask) { > BugzillaTask bugzillaTask = (BugzillaTask) task; > if (bugzillaTask.getBugReport() != null) { >- for (Comment comment : bugzillaTask.getBugReport().getComments()) { >- if (comment.hasAttachment() && comment.getAttachmentDescription().equals(MYLAR_CONTEXT_DESCRIPTION)) { >- contextDelegates.add(new BugzillaRemoteContextDelegate(comment)); >+ for (ReportAttachment attachment : bugzillaTask.getBugReport().getAttachments()) { >+ if (attachment.getDescription().equals(MYLAR_CONTEXT_DESCRIPTION)) { >+ contextDelegates.add(new BugzillaRemoteContextDelegate(attachment)); > } > } >+ // for (Comment comment : >+ // bugzillaTask.getBugReport().getComments()) { >+ // if (comment.hasAttachment() && >+ // comment.getAttachmentDescription().equals(MYLAR_CONTEXT_DESCRIPTION)) >+ // { >+ // contextDelegates.add(new >+ // BugzillaRemoteContextDelegate(comment)); >+ // } >+ // } > } > } > return contextDelegates; >Index: src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java,v >retrieving revision 1.4 >diff -u -r1.4 BugzillaTaskEditorInput.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java 20 Feb 2006 19:53:46 -0000 1.4 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java 8 May 2006 23:07:32 -0000 >@@ -18,7 +18,7 @@ > import javax.security.auth.login.LoginException; > > import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.internal.bugzilla.ui.editor.ExistingBugEditorInput; > import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryTask; > import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryTask.RepositoryTaskSyncState; >@@ -32,7 +32,7 @@ > > private String bugTitle; > >- private BugReport offlineBug; >+ private BugzillaReport offlineBug; > > private BugzillaTask bugTask; > >@@ -99,7 +99,7 @@ > /** > * Returns the offline bug for this input's Bugzilla task > */ >- public BugReport getOfflineBug() { >+ public BugzillaReport getOfflineBug() { > if (offline || bugTask.getSyncState() == RepositoryTaskSyncState.OUTGOING > || bugTask.getSyncState() == RepositoryTaskSyncState.CONFLICT) > return offlineBug; >@@ -107,7 +107,7 @@ > return super.getBug(); > } > >- public void setOfflineBug(BugReport offlineBug) { >+ public void setOfflineBug(BugzillaReport offlineBug) { > this.offlineBug = offlineBug; > } > >Index: src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java,v >retrieving revision 1.8 >diff -u -r1.8 BugzillaRepositorySettingsPage.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java 17 Mar 2006 19:48:15 -0000 1.8 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java 8 May 2006 23:07:32 -0000 >@@ -24,6 +24,7 @@ > import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; > import org.eclipse.mylar.internal.tasklist.ui.wizards.AbstractRepositorySettingsPage; >+import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector; > import org.eclipse.mylar.provisional.tasklist.TaskRepository; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.SelectionEvent; >@@ -40,10 +41,10 @@ > private static final String TITLE = "Bugzilla Repository Settings"; > > private static final String DESCRIPTION = "Example: https://bugs.eclipse.org/bugs (do not include index.cgi)"; >- private BugzillaRepositoryConnector connector; >+ private AbstractRepositoryConnector connector; > protected Combo repositoryVersionCombo; > >- public BugzillaRepositorySettingsPage(BugzillaRepositoryConnector connector) { >+ public BugzillaRepositorySettingsPage(AbstractRepositoryConnector connector) { > super(TITLE, DESCRIPTION); > this.connector = connector; > } >Index: src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaTaskEditor.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaTaskEditor.java,v >retrieving revision 1.7 >diff -u -r1.7 BugzillaTaskEditor.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaTaskEditor.java 18 Apr 2006 22:49:03 -0000 1.7 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/tasklist/BugzillaTaskEditor.java 8 May 2006 23:07:32 -0000 >@@ -16,7 +16,7 @@ > import org.eclipse.core.resources.IMarker; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.jface.dialogs.MessageDialog; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaAttributeListener; > import org.eclipse.mylar.internal.bugzilla.ui.editor.AbstractBugEditor; > import org.eclipse.mylar.internal.bugzilla.ui.editor.BugzillaOutlineNode; >@@ -42,7 +42,7 @@ > protected BugzillaTask bugTask; > > /** This bug report can be modified by the user and saved offline. */ >- protected BugReport offlineBug; >+ protected BugzillaReport offlineBug; > > private ExistingBugEditor bugzillaEditor; > >@@ -189,7 +189,7 @@ > /** > * @return Returns the offlineBug. > */ >- public BugReport getOfflineBug() { >+ public BugzillaReport getOfflineBug() { > return offlineBug; > } > >@@ -270,7 +270,7 @@ > // } > // } > >- public void makeNewPage(BugReport serverBug, String newCommentText) { >+ public void makeNewPage(BugzillaReport serverBug, String newCommentText) { > if (serverBug == null) { > MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), > "Could not open bug.", "Bug #" + offlineBug.getId() >Index: src/org/eclipse/mylar/internal/bugzilla/ui/editor/ExistingBugEditor.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/editor/ExistingBugEditor.java,v >retrieving revision 1.28 >diff -u -r1.28 ExistingBugEditor.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/editor/ExistingBugEditor.java 6 Apr 2006 18:19:59 -0000 1.28 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/editor/ExistingBugEditor.java 8 May 2006 23:07:32 -0000 >@@ -34,8 +34,8 @@ > import org.eclipse.jface.text.TextViewer; > import org.eclipse.jface.viewers.SelectionChangedEvent; > import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.bugzilla.core.Comment; > import org.eclipse.mylar.bugzilla.core.IBugzillaBug; > import org.eclipse.mylar.bugzilla.core.Operation; >@@ -44,16 +44,14 @@ > import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; > import org.eclipse.mylar.internal.bugzilla.core.compare.BugzillaCompareInput; >-import org.eclipse.mylar.internal.bugzilla.core.internal.HtmlStreamTokenizer; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; > import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaRepositoryConnector; >-import org.eclipse.mylar.internal.tasklist.ui.TaskUiUtil; > import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.CCombo; > import org.eclipse.swt.custom.StyledText; > import org.eclipse.swt.events.ModifyEvent; > import org.eclipse.swt.events.ModifyListener; >-import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.events.SelectionListener; > import org.eclipse.swt.layout.GridData; >@@ -62,7 +60,6 @@ > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Event; >-import org.eclipse.swt.widgets.Link; > import org.eclipse.swt.widgets.List; > import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Text; >@@ -95,7 +92,7 @@ > > private static final String LABEL_COMPARE_BUTTON = "Compare"; > >- private static final String ATTR_SUMMARY = "Summary"; >+ // private static final String ATTR_SUMMARY = "Summary"; > > protected Set<String> removeCC = new HashSet<String>(); > >@@ -117,7 +114,7 @@ > > protected Text addCommentsText; > >- protected BugReport bug; >+ protected BugzillaReport bug; > > public String getNewCommentText() { > return addCommentsTextBox.getText(); >@@ -246,10 +243,10 @@ > radioData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); > radioData.horizontalSpan = 1; > radioData.widthHint = 120; >- >+ > // TODO: add condition for if opName = reassign to... > String assignmentValue = ""; >- if(opName.equals(REASSIGN_BUG_TO)) { >+ if (opName.equals(REASSIGN_BUG_TO)) { > assignmentValue = repository.getUserName(); > } > radioOptions[i] = toolkit.createText(buttonComposite, assignmentValue);// , >@@ -289,11 +286,11 @@ > super.addActionButtons(buttonComposite); > > compareButton = toolkit.createButton(buttonComposite, LABEL_COMPARE_BUTTON, SWT.NONE); >-// compareButton.setFont(TEXT_FONT); >+ // compareButton.setFont(TEXT_FONT); > GridData compareButtonData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >-// compareButtonData.widthHint = 100; >-// compareButtonData.heightHint = 20; >-// // compareButton.setText("Compare"); >+ // compareButtonData.widthHint = 100; >+ // compareButtonData.heightHint = 20; >+ // // compareButton.setText("Compare"); > compareButton.setLayoutData(compareButtonData); > compareButton.addListener(SWT.Selection, new Listener() { > public void handleEvent(Event e) { >@@ -317,8 +314,7 @@ > > } > }); >- >- >+ > // TODO used for spell checking. Add back when we want to support this > // checkSpellingButton = new Button(buttonComposite, SWT.NONE); > // checkSpellingButton.setFont(TEXT_FONT); >@@ -350,8 +346,9 @@ > > @Override > protected String getTitleString() { >-// Attribute summary = bug.getAttribute(ATTR_SUMMARY); >-// String summaryVal = ((null != summary) ? summary.getNewValue() : null); >+ // Attribute summary = bug.getAttribute(ATTR_SUMMARY); >+ // String summaryVal = ((null != summary) ? summary.getNewValue() : >+ // null); > return bug.getLabel();// + ": " + checkText(summaryVal); > } > >@@ -430,9 +427,9 @@ > descriptionLayout.numColumns = 1; > descriptionComposite.setLayout(descriptionLayout); > // descriptionComposite.setBackground(background); >- //GridData descriptionData = new GridData(GridData.FILL_HORIZONTAL); >- //descriptionData.horizontalSpan = 1; >- //descriptionData.grabExcessVerticalSpace = false; >+ // GridData descriptionData = new GridData(GridData.FILL_HORIZONTAL); >+ // descriptionData.horizontalSpan = 1; >+ // descriptionData.grabExcessVerticalSpace = false; > // descriptionComposite.setLayoutData(descriptionData); > // End Description Area > >@@ -442,9 +439,10 @@ > // HEADER); > > // t.addListener(SWT.FocusIn, new DescriptionListener()); >- //StyledText t = newLayout(descriptionComposite, 4, bug.getDescription(), VALUE); >+ // StyledText t = newLayout(descriptionComposite, 4, >+ // bug.getDescription(), VALUE); > // t.setFont(COMMENT_FONT); >- >+ > TextViewer viewer = addRepositoryText(repository, descriptionComposite, bug.getDescription()); > StyledText styledText = viewer.getTextWidget(); > styledText.addListener(SWT.FocusIn, new DescriptionListener()); >@@ -489,22 +487,24 @@ > addCommentsData.heightHint = DESCRIPTION_HEIGHT; > addCommentsData.grabExcessVerticalSpace = false; > addCommentsComposite.setLayoutData(addCommentsData); >- // End Additional (read-only) Comments Area >- >- >+ // End Additional (read-only) Comments Area > > StyledText styledText = null; > for (Iterator<Comment> it = bug.getComments().iterator(); it.hasNext();) { > final Comment comment = it.next(); >- >+ >+ // skip comment 0 as it is the description >+ if(comment.getNumber() == 0) continue; >+ > ExpandableComposite ec = toolkit.createExpandableComposite(addCommentsComposite, > ExpandableComposite.TREE_NODE); > > if (!it.hasNext()) { > ec.setExpanded(true); > } >- >- ec.setText(comment.getNumber() + ": " +comment.getAuthorName() + ", " + simpleDateFormat.format(comment.getCreated())); >+ >+ ec.setText(comment.getNumber() + ": " + comment.getAuthorName() + ", " >+ + simpleDateFormat.format(comment.getCreated())); > > ec.addExpansionListener(new ExpansionAdapter() { > public void expansionStateChanged(ExpansionEvent e) { >@@ -519,44 +519,47 @@ > ec.setClient(ecComposite); > toolkit.paintBordersFor(ec); > >- if (comment.hasAttachment()) { >- >- Link attachmentLink = new Link(ecComposite, SWT.NONE); >- >- String attachmentHeader; >- >- if(!comment.isObsolete()) { >- attachmentHeader = " Attached: " + comment.getAttachmentDescription() + " [<a>view</a>]"; >- } else { >- attachmentHeader = " Deprecated: " + comment.getAttachmentDescription(); >- } >- // String result = MessageFormat.format(attachmentHeader, new >- // String[] { node >- // .getLabelText() }); >- >- attachmentLink.addSelectionListener(new SelectionAdapter() { >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) >- */ >- public void widgetSelected(SelectionEvent e) { >- String address = repository.getUrl() + "/attachment.cgi?id=" + comment.getAttachmentId() >- + "&action=view"; >- TaskUiUtil.openUrl(address, address, address); >- >- } >- }); >- >- attachmentLink.setText(attachmentHeader); >- >- } >+ >+ // TODO: Attachments are no longer 'attached' to Comments >+ >+// if (comment.hasAttachment()) { >+// >+// Link attachmentLink = new Link(ecComposite, SWT.NONE); >+// >+// String attachmentHeader; >+// >+// if (!comment.isObsolete()) { >+// attachmentHeader = " Attached: " + comment.getAttachmentDescription() + " [<a>view</a>]"; >+// } else { >+// attachmentHeader = " Deprecated: " + comment.getAttachmentDescription(); >+// } >+// // String result = MessageFormat.format(attachmentHeader, new >+// // String[] { node >+// // .getLabelText() }); >+// >+// attachmentLink.addSelectionListener(new SelectionAdapter() { >+// /* >+// * (non-Javadoc) >+// * >+// * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) >+// */ >+// public void widgetSelected(SelectionEvent e) { >+// String address = repository.getUrl() + "/attachment.cgi?id=" + comment.getAttachmentId() >+// + "&action=view"; >+// TaskUiUtil.openUrl(address, address, address); >+// >+// } >+// }); >+// >+// attachmentLink.setText(attachmentHeader); >+// >+// } > > // styledText = newLayout(ecComposite, 1, comment.getText(), VALUE); > // styledText.addListener(SWT.FocusIn, new > // CommentListener(comment)); > // styledText.setFont(COMMENT_FONT); >- >+ //System.err.println(comment.getNumber()+" "+comment.getText()); > TextViewer viewer = addRepositoryText(repository, ecComposite, comment.getText()); > styledText = viewer.getTextWidget(); > >@@ -593,7 +596,7 @@ > addCommentsText.setFont(COMMENT_FONT); > toolkit.paintBordersFor(newCommentsComposite); > GridData addCommentsTextData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >- //addCommentsTextData.horizontalSpan = 4; >+ // addCommentsTextData.horizontalSpan = 4; > addCommentsTextData.widthHint = DESCRIPTION_WIDTH; > addCommentsTextData.heightHint = DESCRIPTION_HEIGHT; > addCommentsTextData.grabExcessHorizontalSpace = true; >@@ -604,8 +607,8 @@ > > public void handleEvent(Event event) { > String sel = addCommentsText.getText(); >- if (!(bug.getNewNewComment().equals(sel))) { >- bug.setNewNewComment(sel); >+ if (!(bug.getNewComment().equals(sel))) { >+ bug.setNewComment(sel); > changeDirtyStatus(true); > } > validateInput(); >@@ -645,9 +648,13 @@ > keyWordsList.setLayoutData(keyWordsTextData); > > // initialize the keywords list with valid values >- java.util.List<String> keywordList = bug.getKeywords(); >- if (keywordList != null) { >- for (Iterator<String> it = keywordList.iterator(); it.hasNext();) { >+ >+ >+ >+ java.util.List<String> validKeywords = BugzillaPlugin.getDefault().getProductConfiguration(repository).getKeywords(); >+ >+ if (validKeywords != null) { >+ for (Iterator<String> it = validKeywords.iterator(); it.hasNext();) { > String keyword = it.next(); > keyWordsList.add(keyword); > } >@@ -674,7 +681,7 @@ > keyWordsList.addSelectionListener(new KeywordListener()); > keyWordsList.addListener(SWT.FocusIn, new GenericListener()); > } >- >+ > @Override > protected void addCCList(FormToolkit toolkit, String ccValue, Composite attributesComposite) { > newLayout(attributesComposite, 1, "Add CC:", PROPERTY); >@@ -693,9 +700,9 @@ > > public void modifyText(ModifyEvent e) { > changeDirtyStatus(true); >- Attribute a = bug.getAttributeForKnobName("newcc"); >+ AbstractRepositoryReportAttribute a = bug.getAttribute(BugzillaReportElement.NEWCC); > if (a != null) { >- a.setNewValue(ccText.getText()); >+ a.setValue(ccText.getText()); > } > } > >@@ -713,12 +720,11 @@ > ccListData.heightHint = 40; > ccList.setLayoutData(ccListData); > >- // initialize the keywords list with valid values >- Set<String> ccs = bug.getCC(); >+ java.util.List<String> ccs = bug.getCC(); > if (ccs != null) { > for (Iterator<String> it = ccs.iterator(); it.hasNext();) { > String cc = it.next(); >- ccList.add(HtmlStreamTokenizer.unescape(cc)); >+ ccList.add(cc);//HtmlStreamTokenizer.unescape(cc)); > } > } > >@@ -745,23 +751,26 @@ > > @Override > protected void updateBug() { >- >+ bug.setHasChanged(true); > // go through all of the attributes and update the main values to the > // new ones >- for (Iterator<Attribute> it = bug.getAttributes().iterator(); it.hasNext();) { >- Attribute a = it.next(); >- if (a.getNewValue() != null && a.getNewValue().compareTo(a.getValue()) != 0) { >- bug.setHasChanged(true); >- } >- a.setValue(a.getNewValue()); >- >- } >- if (bug.getNewComment().compareTo(bug.getNewNewComment()) != 0) { >- bug.setHasChanged(true); >- } >+ // for (Iterator<AbstractRepositoryReportAttribute> it = >+ // bug.getAttributes().iterator(); it.hasNext();) { >+ // AbstractRepositoryReportAttribute a = it.next(); >+ // if (a.getNewValue() != null && >+ // a.getNewValue().compareTo(a.getValue()) != 0) { >+ // bug.setHasChanged(true); >+ // } >+ // a.setValue(a.getNewValue()); >+ // >+ // } >+ // if (bug.getNewComment().compareTo(bug.getNewNewComment()) != 0) { >+ // // TODO: Ask offline reports if this is true? >+ // bug.setHasChanged(true); >+ // } > > // Update some other fields as well. >- bug.setNewComment(bug.getNewNewComment()); >+ // bug.setNewComment(bug.getNewNewComment()); > > } > >@@ -773,13 +782,14 @@ > > // go through all of the attributes and restore the new values to the > // main ones >- for (Iterator<Attribute> it = bug.getAttributes().iterator(); it.hasNext();) { >- Attribute a = it.next(); >- a.setNewValue(a.getValue()); >- } >+ // for (Iterator<AbstractRepositoryReportAttribute> it = >+ // bug.getAttributes().iterator(); it.hasNext();) { >+ // AbstractRepositoryReportAttribute a = it.next(); >+ // a.setNewValue(a.getValue()); >+ // } > > // Restore some other fields as well. >- bug.setNewNewComment(bug.getNewComment()); >+ // bug.setNewNewComment(bug.getNewComment()); > } > > /** >@@ -794,7 +804,7 @@ > > @Override > protected IStatus run(IProgressMonitor monitor) { >- final BugReport serverBug; >+ final BugzillaReport serverBug; > try { > serverBug = BugzillaRepositoryUtil.getBug(bug.getRepositoryUrl(), bug.getId()); > // If no bug was found on the server, throw an exception so that >@@ -845,7 +855,7 @@ > if (keyWordsList.getSelectionCount() == 1) { > int index = keyWordsList.getSelectionIndex(); > String keyword = keyWordsList.getItem(index); >- if (bug.getAttribute("Keywords").getNewValue().equals(keyword)) >+ if (getReport().getAttributeValue(BugzillaReportElement.KEYWORDS).equals(keyword)) > keyWordsList.deselectAll(); > } > >@@ -855,7 +865,8 @@ > keywords.append(","); > } > } >- bug.getAttribute("Keywords").setNewValue(keywords.toString()); >+ >+ bug.setAttributeValue(BugzillaReportElement.KEYWORDS, keywords.toString()); > > // update the keywords text field > keywordsText.setText(keywords.toString()); >@@ -1003,6 +1014,7 @@ > Operation o = bug.getSelectedOperation(); > if (o != null && o.getKnobName().compareTo("resolve") == 0 > && (addCommentsText.getText() == null || addCommentsText.getText().equals(""))) { >+ // TODO: Highlight (change to light red?) New Comment area to indicate need for message > submitButton.setEnabled(false); > } else { > submitButton.setEnabled(true); >@@ -1012,9 +1024,9 @@ > @Override > public void handleSummaryEvent() { > String sel = summaryText.getText(); >- Attribute a = getBug().getAttribute(ATTR_SUMMARY); >- if (!(a.getNewValue().equals(sel))) { >- a.setNewValue(sel); >+ AbstractRepositoryReportAttribute a = getReport().getAttribute(BugzillaReportElement.SHORT_DESC); >+ if (!(a.getValue().equals(sel))) { >+ a.setValue(sel); > changeDirtyStatus(true); > } > } >Index: src/org/eclipse/mylar/internal/bugzilla/ui/editor/NewBugEditor.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/editor/NewBugEditor.java,v >retrieving revision 1.9 >diff -u -r1.9 NewBugEditor.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/editor/NewBugEditor.java 14 Mar 2006 22:50:52 -0000 1.9 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/editor/NewBugEditor.java 8 May 2006 23:07:32 -0000 >@@ -10,18 +10,15 @@ > *******************************************************************************/ > package org.eclipse.mylar.internal.bugzilla.ui.editor; > >-import java.util.Iterator; >- > import org.eclipse.core.runtime.Status; > import org.eclipse.core.runtime.jobs.IJobChangeEvent; > import org.eclipse.core.runtime.jobs.IJobChangeListener; > import org.eclipse.jface.viewers.SelectionChangedEvent; > import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.mylar.bugzilla.core.Attribute; > import org.eclipse.mylar.bugzilla.core.IBugzillaBug; >-import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportSubmitForm; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >+import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportSubmitForm; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; > import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaRepositoryConnector; > import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin; > import org.eclipse.mylar.provisional.tasklist.TaskRepository; >@@ -48,7 +45,7 @@ > */ > public class NewBugEditor extends AbstractBugEditor { > >- protected NewBugModel bug; >+ protected NewBugzillaReport bug; > > protected Text descriptionText; > >@@ -270,10 +267,10 @@ > protected void updateBug() { > // go through all of the attributes and update the main values to the > // new ones >- for (Iterator<Attribute> it = bug.getAttributes().iterator(); it.hasNext();) { >- Attribute a = it.next(); >- a.setValue(a.getNewValue()); >- } >+// for (Iterator<AbstractRepositoryReportAttribute> it = bug.getAttributes().iterator(); it.hasNext();) { >+// AbstractRepositoryReportAttribute a = it.next(); >+// a.setValue(a.getNewValue()); >+// } > > // Update some other fields as well. > bug.setSummary(newSummary); >@@ -284,10 +281,10 @@ > protected void restoreBug() { > // go through all of the attributes and restore the new values to the > // main ones >- for (Iterator<Attribute> it = bug.getAttributes().iterator(); it.hasNext();) { >- Attribute a = it.next(); >- a.setNewValue(a.getValue()); >- } >+// for (Iterator<AbstractRepositoryReportAttribute> it = bug.getAttributes().iterator(); it.hasNext();) { >+// AbstractRepositoryReportAttribute a = it.next(); >+// a.setNewValue(a.getValue()); >+// } > } > > @SuppressWarnings("deprecation") >Index: src/org/eclipse/mylar/internal/bugzilla/ui/editor/AbstractBugEditor.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/editor/AbstractBugEditor.java,v >retrieving revision 1.34 >diff -u -r1.34 AbstractBugEditor.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/editor/AbstractBugEditor.java 6 Apr 2006 18:19:59 -0000 1.34 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/editor/AbstractBugEditor.java 8 May 2006 23:07:31 -0000 >@@ -14,7 +14,6 @@ > import java.util.ArrayList; > import java.util.Arrays; > import java.util.HashMap; >-import java.util.Iterator; > import java.util.List; > import java.util.Map; > import java.util.Set; >@@ -35,7 +34,9 @@ > import org.eclipse.jface.viewers.ISelectionProvider; > import org.eclipse.jface.viewers.SelectionChangedEvent; > import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.mylar.bugzilla.core.Attribute; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReport; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.bugzilla.core.Comment; > import org.eclipse.mylar.bugzilla.core.IBugzillaBug; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; >@@ -43,6 +44,7 @@ > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaAttributeListener; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaReportSelection; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; > import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaRepositoryConnector; > import org.eclipse.mylar.internal.core.util.MylarStatusHandler; > import org.eclipse.mylar.internal.tasklist.ui.editors.MylarTaskEditor; >@@ -170,7 +172,7 @@ > > protected final int HORZ_INDENT = 0; > >- protected CCombo oSCombo; >+ protected CCombo attributeCombo; > > protected CCombo versionCombo; > >@@ -257,7 +259,7 @@ > > protected List<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>(); > >- protected HashMap<CCombo, String> comboListenerMap = new HashMap<CCombo, String>(); >+ protected HashMap<CCombo, AbstractRepositoryReportAttribute> comboListenerMap = new HashMap<CCombo, AbstractRepositoryReportAttribute>(); > > private IBugzillaReportSelection lastSelected = null; > >@@ -309,9 +311,9 @@ > if (comboListenerMap.containsKey(combo)) { > if (combo.getSelectionIndex() > -1) { > String sel = combo.getItem(combo.getSelectionIndex()); >- Attribute attribute = getBug().getAttribute(comboListenerMap.get(combo)); >- if (sel != null && !(sel.equals(attribute.getNewValue()))) { >- attribute.setNewValue(sel); >+ AbstractRepositoryReportAttribute attribute = comboListenerMap.get(combo); >+ if (sel != null && !(sel.equals(attribute.getValue()))) { >+ attribute.setValue(sel); > for (IBugzillaAttributeListener client : attributesListeners) { > client.attributeChanged(attribute.getName(), sel); > } >@@ -382,6 +384,11 @@ > */ > public abstract IBugzillaBug getBug(); > >+ // TODO: temporary as part of conversion to xml >+ public AbstractRepositoryReport getReport() { >+ return (AbstractRepositoryReport) getBug(); >+ } >+ > /** > * @return Any currently selected text. > */ >@@ -429,7 +436,7 @@ > Composite headerInfoComposite = toolkit.createComposite(editorComposite); > headerInfoComposite.setLayout(new GridLayout(6, false)); > toolkit.createLabel(headerInfoComposite, "Bug# ").setFont(TITLE_FONT); >- toolkit.createText(headerInfoComposite, "" + getBug().getId()); >+ toolkit.createText(headerInfoComposite, "" + getReport().getId()); > > toolkit.createLabel(headerInfoComposite, " Opened: ").setFont(TITLE_FONT); > String openedDateString = ""; >@@ -490,6 +497,387 @@ > getSite().registerContextMenu("#BugEditor", contextMenuManager, getSite().getSelectionProvider()); > } > >+ // /** >+ // * Creates the attribute layout, which contains most of the basic >+ // attributes >+ // * of the bug (some of which are editable). >+ // */ >+ // protected void createAttributeLayout() { >+ // >+ // String title = getTitleString(); >+ // String keywords = ""; >+ // String url = ""; >+ // >+ // Section section = toolkit.createSection(form.getBody(), >+ // ExpandableComposite.TITLE_BAR | Section.TWISTIE); >+ // section.setText(LABEL_SECTION_ATTRIBUTES); >+ // section.setExpanded(true); >+ // section.setLayout(new GridLayout()); >+ // section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ // >+ // section.addExpansionListener(new IExpansionListener() { >+ // public void expansionStateChanging(ExpansionEvent e) { >+ // form.reflow(true); >+ // } >+ // >+ // public void expansionStateChanged(ExpansionEvent e) { >+ // form.reflow(true); >+ // } >+ // }); >+ // >+ // // Attributes Composite- this holds all the combo fiels and text fields >+ // Composite attributesComposite = toolkit.createComposite(section); >+ // GridLayout attributesLayout = new GridLayout(); >+ // attributesLayout.numColumns = 4; >+ // attributesLayout.horizontalSpacing = 14; >+ // attributesLayout.verticalSpacing = 6; >+ // attributesComposite.setLayout(attributesLayout); >+ // GridData attributesData = new GridData(GridData.FILL_BOTH); >+ // attributesData.horizontalSpan = 1; >+ // attributesData.grabExcessVerticalSpace = false; >+ // attributesComposite.setLayoutData(attributesData); >+ // // attributesComposite.setBackground(background); >+ // // End Attributes Composite >+ // >+ // section.setClient(attributesComposite); >+ // >+ // // Attributes Title Area >+ // // Composite attributesTitleComposite = new >+ // // Composite(attributesComposite, SWT.NONE); >+ // // GridLayout attributesTitleLayout = new GridLayout(); >+ // // attributesTitleLayout.horizontalSpacing = 0; >+ // // attributesTitleLayout.marginWidth = 0; >+ // // attributesTitleComposite.setLayout(attributesTitleLayout); >+ // // attributesTitleComposite.setBackground(background); >+ // // GridData attributesTitleData = new >+ // // GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ // // attributesTitleData.horizontalSpan = 4; >+ // // attributesTitleData.grabExcessVerticalSpace = false; >+ // // attributesTitleComposite.setLayoutData(attributesTitleData); >+ // // End Attributes Title >+ // >+ // // Set the Attributes Title >+ // // newAttributesLayout(attributesTitleComposite); >+ // // titleLabel.setText(title); >+ // bugzillaInput.setToolTipText(title); >+ // int currentCol = 1; >+ // >+ // // String ccValue = null; >+ // >+ // // Populate Attributes >+ // for (Iterator<AbstractRepositoryReportAttribute> it = >+ // getReport().getAttributes().iterator(); it.hasNext();) { >+ // AbstractRepositoryReportAttribute attribute = it.next(); >+ // String key = attribute.getID(); >+ // String name = attribute.getName(); >+ // String value = checkText(attribute.getValue()); >+ // System.err.println(">>> AbstractBugEditor>> name: "+name+" key: "+key+" >+ // value:"+value); >+ // Map<String, String> values = attribute.getOptionValues(); >+ // >+ // // make sure we don't try to display a hidden field >+ // if (attribute.isHidden() || (key != null && >+ // key.equals("status_whiteboard"))) >+ // continue; >+ // >+ // if (values == null) >+ // values = new HashMap<String, String>(); >+ // >+ // if (key == null) >+ // key = ""; >+ // >+ // GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ // data.horizontalSpan = 1; >+ // data.horizontalIndent = HORZ_INDENT; >+ // >+ // if (key.equals(BugzillaReportElement.KEYWORDS.getKeyString())) { >+ // keywords = attribute.getValue(); >+ // } else if (key.equals(BugzillaReportElement.CC.getKeyString())) { >+ // continue; >+ // } else if (key.equals(BugzillaReportElement.NEWCC.getKeyString())) { >+ // // force move to first column >+ // if (currentCol > 1) { >+ // while (currentCol <= attributesLayout.numColumns) { >+ // newLayout(attributesComposite, 1, "", PROPERTY); >+ // currentCol++; >+ // } >+ // } >+ // addCCList(toolkit, "", attributesComposite); >+ // } else if (key.equals(BugzillaReportElement.DEPENDSON.getKeyString())) { >+ // // Dependson and blocked are multi valued so need to explicitly >+ // // be parsed and shown in the AbstractBugEditor >+ // continue; >+ // } else if (key.equals(BugzillaReportElement.BLOCKED.getKeyString())) { >+ // // Dependson and blocked are multi valued so need to explicitly >+ // // be parsed and shown in the AbstractBugEditor >+ // continue; >+ // } else if (key.equals("bug_file_loc")) { >+ // url = value; >+ // } else if (key.equals("op_sys")) { >+ // // newLayout(attributesComposite, 1, name, PROPERTY); >+ // toolkit.createLabel(attributesComposite, name); >+ // // oSCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | >+ // // SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY);//SWT.NONE >+ // oSCombo = new CCombo(attributesComposite, SWT.FLAT | SWT.READ_ONLY); >+ // // oSCombo = new Combo(attributesComposite, SWT.FLAT | >+ // // SWT.READ_ONLY); >+ // toolkit.adapt(oSCombo, true, true); >+ // oSCombo.setFont(TEXT_FONT); >+ // oSCombo.setLayoutData(data); >+ // // oSCombo.setBackground(background); >+ // Set<String> s = values.keySet(); >+ // String[] a = s.toArray(new String[s.size()]); >+ // Arrays.sort(a); >+ // for (int i = 0; i < a.length; i++) { >+ // oSCombo.add(a[i]); >+ // } >+ // if (oSCombo.indexOf(value) != -1) { >+ // oSCombo.select(oSCombo.indexOf(value)); >+ // } else { >+ // oSCombo.select(oSCombo.indexOf("All")); >+ // } >+ // // oSCombo.addListener(SWT.Modify, this); >+ // oSCombo.addSelectionListener(new ComboSelectionListener(oSCombo)); >+ // comboListenerMap.put(oSCombo, attribute); >+ // oSCombo.addListener(SWT.FocusIn, new GenericListener()); >+ // currentCol += 2; >+ // } else if (key.equals("version")) { >+ // // newLayout(attributesComposite, 1, name, PROPERTY); >+ // toolkit.createLabel(attributesComposite, name); >+ // versionCombo = new CCombo(attributesComposite, SWT.FLAT | >+ // SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL >+ // | SWT.READ_ONLY); >+ // toolkit.adapt(versionCombo, true, true); >+ // versionCombo.setFont(TEXT_FONT); >+ // versionCombo.setLayoutData(data); >+ // // versionCombo.setBackground(background); >+ // Set<String> s = values.keySet(); >+ // String[] a = s.toArray(new String[s.size()]); >+ // Arrays.sort(a); >+ // for (int i = 0; i < a.length; i++) { >+ // versionCombo.add(a[i]); >+ // } >+ // versionCombo.select(versionCombo.indexOf(value)); >+ // // versionCombo.addListener(SWT.Modify, this); >+ // versionCombo.addSelectionListener(new >+ // ComboSelectionListener(versionCombo)); >+ // versionCombo.addListener(SWT.FocusIn, new GenericListener()); >+ // comboListenerMap.put(versionCombo, attribute); >+ // currentCol += 2; >+ // } else if (key.equals("priority")) { >+ // // newLayout(attributesComposite, 1, "Priority", PROPERTY); >+ // toolkit.createLabel(attributesComposite, name); >+ // priorityCombo = new CCombo(attributesComposite, SWT.FLAT | SWT.V_SCROLL | >+ // SWT.READ_ONLY); >+ // toolkit.adapt(priorityCombo, true, true); >+ // priorityCombo.setFont(TEXT_FONT); >+ // priorityCombo.setLayoutData(data); >+ // // priorityCombo.setBackground(background); >+ // Set<String> s = values.keySet(); >+ // String[] a = s.toArray(new String[s.size()]); >+ // Arrays.sort(a); >+ // for (int i = 0; i < a.length; i++) { >+ // priorityCombo.add(a[i]); >+ // } >+ // priorityCombo.select(priorityCombo.indexOf(value)); >+ // // priorityCombo.addListener(SWT.Modify, this); >+ // priorityCombo.addSelectionListener(new >+ // ComboSelectionListener(priorityCombo)); >+ // priorityCombo.addListener(SWT.FocusIn, new GenericListener()); >+ // comboListenerMap.put(priorityCombo, attribute); >+ // currentCol += 2; >+ // } else if (key.equals("bug_severity")) { >+ // // newLayout(attributesComposite, 1, name, PROPERTY); >+ // toolkit.createLabel(attributesComposite, name); >+ // severityCombo = new CCombo(attributesComposite, SWT.FLAT | >+ // SWT.READ_ONLY); >+ // toolkit.adapt(severityCombo, true, true); >+ // severityCombo.setFont(TEXT_FONT); >+ // severityCombo.setLayoutData(data); >+ // // severityCombo.setBackground(background); >+ // Set<String> s = values.keySet(); >+ // String[] a = s.toArray(new String[s.size()]); >+ // Arrays.sort(a); >+ // for (int i = 0; i < a.length; i++) { >+ // severityCombo.add(a[i]); >+ // } >+ // severityCombo.select(severityCombo.indexOf(value)); >+ // severityCombo.addSelectionListener(new >+ // ComboSelectionListener(severityCombo)); >+ // // severityCombo.addListener(SWT.Modify, this); >+ // severityCombo.addListener(SWT.FocusIn, new GenericListener()); >+ // comboListenerMap.put(severityCombo, attribute); >+ // currentCol += 2; >+ // } else if (key.equals("target_milestone")) { >+ // // newLayout(attributesComposite, 1, name, PROPERTY); >+ // toolkit.createLabel(attributesComposite, name); >+ // milestoneCombo = new CCombo(attributesComposite, SWT.FLAT | >+ // SWT.NO_BACKGROUND | SWT.MULTI >+ // | SWT.V_SCROLL | SWT.READ_ONLY); >+ // toolkit.adapt(milestoneCombo, true, true); >+ // milestoneCombo.setFont(TEXT_FONT); >+ // milestoneCombo.setLayoutData(data); >+ // // milestoneCombo.setBackground(background); >+ // Set<String> s = values.keySet(); >+ // String[] a = s.toArray(new String[s.size()]); >+ // Arrays.sort(a); >+ // for (int i = 0; i < a.length; i++) { >+ // milestoneCombo.add(a[i]); >+ // } >+ // milestoneCombo.select(milestoneCombo.indexOf(value)); >+ // // milestoneCombo.addListener(SWT.Modify, this); >+ // milestoneCombo.addSelectionListener(new >+ // ComboSelectionListener(milestoneCombo)); >+ // milestoneCombo.addListener(SWT.FocusIn, new GenericListener()); >+ // comboListenerMap.put(milestoneCombo, attribute); >+ // currentCol += 2; >+ // } else if (key.equals("rep_platform")) { >+ // // newLayout(attributesComposite, 1, name, PROPERTY); >+ // toolkit.createLabel(attributesComposite, name); >+ // platformCombo = new CCombo(attributesComposite, SWT.FLAT | >+ // SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL >+ // | SWT.READ_ONLY); >+ // toolkit.adapt(platformCombo, true, true); >+ // platformCombo.setFont(TEXT_FONT); >+ // platformCombo.setLayoutData(data); >+ // // platformCombo.setBackground(background); >+ // Set<String> s = values.keySet(); >+ // String[] a = s.toArray(new String[s.size()]); >+ // Arrays.sort(a); >+ // for (int i = 0; i < a.length; i++) { >+ // platformCombo.add(a[i]); >+ // } >+ // platformCombo.select(platformCombo.indexOf(value)); >+ // // platformCombo.addListener(SWT.Modify, this); >+ // platformCombo.addSelectionListener(new >+ // ComboSelectionListener(platformCombo)); >+ // platformCombo.addListener(SWT.FocusIn, new GenericListener()); >+ // comboListenerMap.put(platformCombo, attribute); >+ // currentCol += 2; >+ // } else if (key.equals("product")) { >+ // // newLayout(attributesComposite, 1, name, PROPERTY); >+ // toolkit.createLabel(attributesComposite, name); >+ // // toolkit.createLabel(attributesComposite, value); >+ // Composite uneditableComp = toolkit.createComposite(attributesComposite); >+ // GridLayout textLayout = new GridLayout(); >+ // textLayout.marginWidth = 1; >+ // uneditableComp.setLayout(textLayout); >+ // toolkit.createText(uneditableComp, value, SWT.READ_ONLY);// >+ // Label(attributesComposite, >+ // // value); >+ // // newLayout(attributesComposite, 1, value, >+ // // VALUE).addListener(SWT.FocusIn, new GenericListener()); >+ // currentCol += 2; >+ // } else if (key.equals("assigned_to")) { >+ // // newLayout(attributesComposite, 1, name, PROPERTY); >+ // toolkit.createLabel(attributesComposite, name); >+ // assignedTo = new Text(attributesComposite, SWT.SINGLE | SWT.WRAP); >+ // assignedTo.setFont(TEXT_FONT); >+ // assignedTo.setText(value); >+ // data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >+ // data.horizontalSpan = 1; >+ // assignedTo.setLayoutData(data); >+ // >+ // assignedTo.addListener(SWT.KeyUp, new Listener() { >+ // public void handleEvent(Event event) { >+ // String sel = assignedTo.getText(); >+ // AbstractRepositoryReportAttribute a = getReport().getAttribute( >+ // BugzillaReportElement.ASSIGNED_TO); >+ // if (!(a.getValue().equals(sel))) { >+ // a.setValue(sel); >+ // changeDirtyStatus(true); >+ // } >+ // } >+ // }); >+ // assignedTo.addListener(SWT.FocusIn, new GenericListener()); >+ // >+ // currentCol += 2; >+ // } else if (key.equals("component")) { >+ // // newLayout(attributesComposite, 1, name, PROPERTY); >+ // toolkit.createLabel(attributesComposite, name); >+ // componentCombo = new CCombo(attributesComposite, SWT.FLAT | >+ // SWT.NO_BACKGROUND | SWT.MULTI >+ // | SWT.V_SCROLL | SWT.READ_ONLY); >+ // toolkit.adapt(componentCombo, true, true); >+ // componentCombo.setFont(TEXT_FONT); >+ // componentCombo.setLayoutData(data); >+ // // componentCombo.setBackground(background); >+ // Set<String> s = values.keySet(); >+ // String[] a = s.toArray(new String[s.size()]); >+ // Arrays.sort(a); >+ // for (int i = 0; i < a.length; i++) { >+ // componentCombo.add(a[i]); >+ // } >+ // componentCombo.select(componentCombo.indexOf(value)); >+ // // componentCombo.addListener(SWT.Modify, this); >+ // componentCombo.addSelectionListener(new >+ // ComboSelectionListener(componentCombo)); >+ // componentCombo.addListener(SWT.FocusIn, new GenericListener()); >+ // comboListenerMap.put(componentCombo, attribute); >+ // currentCol += 2; >+ // } else if (name.equals("Summary")) { >+ // // Don't show the summary here. >+ // continue; >+ // } else if (name.equals("Last Modified")) { >+ // // Don't show last modified here. >+ // continue; >+ // } else if (name.equals("Bug#")) { >+ // // Don't show bug number here >+ // continue; >+ // } else if (key.equals("bug_status")) { >+ // // newLayout(attributesComposite, 1, name, PROPERTY); >+ // toolkit.createLabel(attributesComposite, name); >+ // Composite uneditableComp = toolkit.createComposite(attributesComposite); >+ // GridLayout textLayout = new GridLayout(); >+ // textLayout.marginWidth = 1; >+ // uneditableComp.setLayout(textLayout); >+ // toolkit.createText(uneditableComp, value, SWT.READ_ONLY);// >+ // Label(attributesComposite, >+ // // value); >+ // // newLayout(attributesComposite, 1, value, >+ // // VALUE).addListener(SWT.FocusIn, new GenericListener()); >+ // currentCol += 2; >+ // } else if (values.isEmpty()) { >+ // // newLayout(attributesComposite, 1, name, PROPERTY); >+ // toolkit.createLabel(attributesComposite, name); >+ // Composite uneditableComp = toolkit.createComposite(attributesComposite); >+ // GridLayout textLayout = new GridLayout(); >+ // textLayout.marginWidth = 1; >+ // uneditableComp.setLayout(textLayout); >+ // toolkit.createText(uneditableComp, value, SWT.READ_ONLY);// >+ // Label(attributesComposite, >+ // // value); >+ // // newLayout(attributesComposite, 1, value, >+ // // VALUE).addListener(SWT.FocusIn, new GenericListener()); >+ // currentCol += 2; >+ // } >+ // if (currentCol > attributesLayout.numColumns) { >+ // currentCol -= attributesLayout.numColumns; >+ // } >+ // } >+ // // End Populate Attributes >+ // >+ // // make sure that we are in the first column >+ // if (currentCol > 1) { >+ // while (currentCol <= attributesLayout.numColumns) { >+ // newLayout(attributesComposite, 1, "", PROPERTY); >+ // currentCol++; >+ // } >+ // } >+ // >+ // // URL field >+ // addUrlText(url, attributesComposite); >+ // >+ // // keywords text field (not editable) >+ // addKeywordsList(toolkit, keywords, attributesComposite); >+ // // if (ccValue != null) { >+ // // addCCList(toolkit, ccValue, attributesComposite); >+ // // } >+ // addSummaryText(attributesComposite); >+ // // End URL, Keywords, Summary Text Fields >+ // toolkit.paintBordersFor(attributesComposite); >+ // } >+ > /** > * Creates the attribute layout, which contains most of the basic attributes > * of the bug (some of which are editable). >@@ -497,9 +885,6 @@ > protected void createAttributeLayout() { > > String title = getTitleString(); >- String keywords = ""; >- String url = ""; >- > Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR | Section.TWISTIE); > section.setText(LABEL_SECTION_ATTRIBUTES); > section.setExpanded(true); >@@ -516,7 +901,7 @@ > } > }); > >- // Attributes Composite- this holds all the combo fiels and text fields >+ // Attributes Composite- this holds all the combo fields and text fields > Composite attributesComposite = toolkit.createComposite(section); > GridLayout attributesLayout = new GridLayout(); > attributesLayout.numColumns = 4; >@@ -527,296 +912,105 @@ > attributesData.horizontalSpan = 1; > attributesData.grabExcessVerticalSpace = false; > attributesComposite.setLayoutData(attributesData); >- // attributesComposite.setBackground(background); >- // End Attributes Composite >- > section.setClient(attributesComposite); >- >- // Attributes Title Area >- // Composite attributesTitleComposite = new >- // Composite(attributesComposite, SWT.NONE); >- // GridLayout attributesTitleLayout = new GridLayout(); >- // attributesTitleLayout.horizontalSpacing = 0; >- // attributesTitleLayout.marginWidth = 0; >- // attributesTitleComposite.setLayout(attributesTitleLayout); >- // attributesTitleComposite.setBackground(background); >- // GridData attributesTitleData = new >- // GridData(GridData.HORIZONTAL_ALIGN_FILL); >- // attributesTitleData.horizontalSpan = 4; >- // attributesTitleData.grabExcessVerticalSpace = false; >- // attributesTitleComposite.setLayoutData(attributesTitleData); >- // End Attributes Title >- >- // Set the Attributes Title >- // newAttributesLayout(attributesTitleComposite); >- // titleLabel.setText(title); > bugzillaInput.setToolTipText(title); >+ > int currentCol = 1; > >- String ccValue = null; >+ for (AbstractRepositoryReportAttribute attribute : getReport().getAttributes()) { > >- // Populate Attributes >- for (Iterator<Attribute> it = getBug().getAttributes().iterator(); it.hasNext();) { >- Attribute attribute = it.next(); >- String key = attribute.getParameterName(); >+ // String key = attribute.getID(); > String name = attribute.getName(); > String value = checkText(attribute.getValue()); >- Map<String, String> values = attribute.getOptionValues(); >- >- // make sure we don't try to display a hidden field >- if (attribute.isHidden() || (key != null && key.equals("status_whiteboard"))) >+ // System.err.println(">>> AbstractBugEditor>> name: "+name+" >+ // key:"+key+" value:"+value+" is hidden"+attribute.isHidden()); >+ if (attribute.isHidden()) > continue; >- >+ Map<String, String> values = attribute.getOptionValues(); > if (values == null) > values = new HashMap<String, String>(); > >- if (key == null) >- key = ""; >- > GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); > data.horizontalSpan = 1; > data.horizontalIndent = HORZ_INDENT; > >- if (key.equals("short_desc") || key.equals("keywords")) { >- keywords = value; >- } else if (key.equals("newcc")) { >- ccValue = value; >- if (value == null) >- ccValue = ""; >- } else if (key.equals("bug_file_loc")) { >- url = value; >- } else if (key.equals("op_sys")) { >- // newLayout(attributesComposite, 1, name, PROPERTY); >- toolkit.createLabel(attributesComposite, name); >- // oSCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | >- // SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY);//SWT.NONE >- oSCombo = new CCombo(attributesComposite, SWT.FLAT | SWT.READ_ONLY); >- // oSCombo = new Combo(attributesComposite, SWT.FLAT | >- // SWT.READ_ONLY); >- toolkit.adapt(oSCombo, true, true); >- oSCombo.setFont(TEXT_FONT); >- oSCombo.setLayoutData(data); >- // oSCombo.setBackground(background); >- Set<String> s = values.keySet(); >- String[] a = s.toArray(new String[s.size()]); >- Arrays.sort(a); >- for (int i = 0; i < a.length; i++) { >- oSCombo.add(a[i]); >- } >- if (oSCombo.indexOf(value) != -1) { >- oSCombo.select(oSCombo.indexOf(value)); >- } else { >- oSCombo.select(oSCombo.indexOf("All")); >- } >- // oSCombo.addListener(SWT.Modify, this); >- oSCombo.addSelectionListener(new ComboSelectionListener(oSCombo)); >- comboListenerMap.put(oSCombo, name); >- oSCombo.addListener(SWT.FocusIn, new GenericListener()); >- currentCol += 2; >- } else if (key.equals("version")) { >- // newLayout(attributesComposite, 1, name, PROPERTY); >- toolkit.createLabel(attributesComposite, name); >- versionCombo = new CCombo(attributesComposite, SWT.FLAT | SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL >- | SWT.READ_ONLY); >- toolkit.adapt(versionCombo, true, true); >- versionCombo.setFont(TEXT_FONT); >- versionCombo.setLayoutData(data); >- // versionCombo.setBackground(background); >- Set<String> s = values.keySet(); >- String[] a = s.toArray(new String[s.size()]); >- Arrays.sort(a); >- for (int i = 0; i < a.length; i++) { >- versionCombo.add(a[i]); >- } >- versionCombo.select(versionCombo.indexOf(value)); >- // versionCombo.addListener(SWT.Modify, this); >- versionCombo.addSelectionListener(new ComboSelectionListener(versionCombo)); >- versionCombo.addListener(SWT.FocusIn, new GenericListener()); >- comboListenerMap.put(versionCombo, name); >- currentCol += 2; >- } else if (key.equals("priority")) { >- // newLayout(attributesComposite, 1, "Priority", PROPERTY); >+ if (attribute.hasOptions() && !attribute.isReadOnly()) { > toolkit.createLabel(attributesComposite, name); >- priorityCombo = new CCombo(attributesComposite, SWT.FLAT | SWT.V_SCROLL | SWT.READ_ONLY); >- toolkit.adapt(priorityCombo, true, true); >- priorityCombo.setFont(TEXT_FONT); >- priorityCombo.setLayoutData(data); >- // priorityCombo.setBackground(background); >+ attributeCombo = new CCombo(attributesComposite, SWT.FLAT | SWT.READ_ONLY); >+ toolkit.adapt(attributeCombo, true, true); >+ attributeCombo.setFont(TEXT_FONT); >+ attributeCombo.setLayoutData(data); > Set<String> s = values.keySet(); > String[] a = s.toArray(new String[s.size()]); > Arrays.sort(a); > for (int i = 0; i < a.length; i++) { >- priorityCombo.add(a[i]); >+ attributeCombo.add(a[i]); > } >- priorityCombo.select(priorityCombo.indexOf(value)); >- // priorityCombo.addListener(SWT.Modify, this); >- priorityCombo.addSelectionListener(new ComboSelectionListener(priorityCombo)); >- priorityCombo.addListener(SWT.FocusIn, new GenericListener()); >- comboListenerMap.put(priorityCombo, name); >- currentCol += 2; >- } else if (key.equals("bug_severity")) { >- // newLayout(attributesComposite, 1, name, PROPERTY); >- toolkit.createLabel(attributesComposite, name); >- severityCombo = new CCombo(attributesComposite, SWT.FLAT | SWT.READ_ONLY); >- toolkit.adapt(severityCombo, true, true); >- severityCombo.setFont(TEXT_FONT); >- severityCombo.setLayoutData(data); >- // severityCombo.setBackground(background); >- Set<String> s = values.keySet(); >- String[] a = s.toArray(new String[s.size()]); >- Arrays.sort(a); >- for (int i = 0; i < a.length; i++) { >- severityCombo.add(a[i]); >+ if (attributeCombo.indexOf(value) != -1) { >+ attributeCombo.select(attributeCombo.indexOf(value)); > } >- severityCombo.select(severityCombo.indexOf(value)); >- severityCombo.addSelectionListener(new ComboSelectionListener(severityCombo)); >- // severityCombo.addListener(SWT.Modify, this); >- severityCombo.addListener(SWT.FocusIn, new GenericListener()); >- comboListenerMap.put(severityCombo, name); >+ attributeCombo.addSelectionListener(new ComboSelectionListener(attributeCombo)); >+ comboListenerMap.put(attributeCombo, attribute); >+ attributeCombo.addListener(SWT.FocusIn, new GenericListener()); > currentCol += 2; >- } else if (key.equals("target_milestone")) { >- // newLayout(attributesComposite, 1, name, PROPERTY); >+ } else { > toolkit.createLabel(attributesComposite, name); >- milestoneCombo = new CCombo(attributesComposite, SWT.FLAT | SWT.NO_BACKGROUND | SWT.MULTI >- | SWT.V_SCROLL | SWT.READ_ONLY); >- toolkit.adapt(milestoneCombo, true, true); >- milestoneCombo.setFont(TEXT_FONT); >- milestoneCombo.setLayoutData(data); >- // milestoneCombo.setBackground(background); >- Set<String> s = values.keySet(); >- String[] a = s.toArray(new String[s.size()]); >- Arrays.sort(a); >- for (int i = 0; i < a.length; i++) { >- milestoneCombo.add(a[i]); >- } >- milestoneCombo.select(milestoneCombo.indexOf(value)); >- // milestoneCombo.addListener(SWT.Modify, this); >- milestoneCombo.addSelectionListener(new ComboSelectionListener(milestoneCombo)); >- milestoneCombo.addListener(SWT.FocusIn, new GenericListener()); >- comboListenerMap.put(milestoneCombo, name); >- currentCol += 2; >- } else if (key.equals("rep_platform")) { >- // newLayout(attributesComposite, 1, name, PROPERTY); >- toolkit.createLabel(attributesComposite, name); >- platformCombo = new CCombo(attributesComposite, SWT.FLAT | SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL >- | SWT.READ_ONLY); >- toolkit.adapt(platformCombo, true, true); >- platformCombo.setFont(TEXT_FONT); >- platformCombo.setLayoutData(data); >- // platformCombo.setBackground(background); >- Set<String> s = values.keySet(); >- String[] a = s.toArray(new String[s.size()]); >- Arrays.sort(a); >- for (int i = 0; i < a.length; i++) { >- platformCombo.add(a[i]); >- } >- platformCombo.select(platformCombo.indexOf(value)); >- // platformCombo.addListener(SWT.Modify, this); >- platformCombo.addSelectionListener(new ComboSelectionListener(platformCombo)); >- platformCombo.addListener(SWT.FocusIn, new GenericListener()); >- comboListenerMap.put(platformCombo, name); >- currentCol += 2; >- } else if (key.equals("product")) { >- // newLayout(attributesComposite, 1, name, PROPERTY); >- toolkit.createLabel(attributesComposite, name); >- // toolkit.createLabel(attributesComposite, value); >- Composite uneditableComp = toolkit.createComposite(attributesComposite); >+ Composite textFieldComposite = toolkit.createComposite(attributesComposite); > GridLayout textLayout = new GridLayout(); > textLayout.marginWidth = 1; >- uneditableComp.setLayout(textLayout); >- toolkit.createText(uneditableComp, value, SWT.READ_ONLY);// Label(attributesComposite, >- // value); >- // newLayout(attributesComposite, 1, value, >- // VALUE).addListener(SWT.FocusIn, new GenericListener()); >- currentCol += 2; >- } else if (key.equals("assigned_to")) { >- // newLayout(attributesComposite, 1, name, PROPERTY); >- toolkit.createLabel(attributesComposite, name); >- assignedTo = new Text(attributesComposite, SWT.BORDER | SWT.SINGLE | SWT.WRAP); >- assignedTo.setFont(TEXT_FONT); >- assignedTo.setText(value); >- data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >- data.horizontalSpan = 1; >- assignedTo.setLayoutData(data); >- >- assignedTo.addListener(SWT.KeyUp, new Listener() { >- public void handleEvent(Event event) { >- String sel = assignedTo.getText(); >- Attribute a = getBug().getAttribute("Assign To"); >- if (!(a.getNewValue().equals(sel))) { >- a.setNewValue(sel); >- changeDirtyStatus(true); >+ textFieldComposite.setLayout(textLayout); >+ GridData textData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ textData.horizontalSpan = 1; >+ textData.widthHint = 135; >+ >+ if (attribute.isReadOnly()) { >+ final Text text = toolkit.createText(textFieldComposite, value, SWT.FLAT | SWT.READ_ONLY); >+ text.setLayoutData(textData); >+ } else { >+ final Text text = toolkit.createText(textFieldComposite, value, SWT.FLAT); >+ text.setLayoutData(textData); >+ toolkit.paintBordersFor(textFieldComposite); >+ text.setData(attribute); >+ text.addListener(SWT.KeyUp, new Listener() { >+ public void handleEvent(Event event) { >+ String sel = text.getText(); >+ AbstractRepositoryReportAttribute a = (AbstractRepositoryReportAttribute) text.getData(); >+ if (!(a.getValue().equals(sel))) { >+ a.setValue(sel); >+ changeDirtyStatus(true); >+ } > } >- } >- }); >- assignedTo.addListener(SWT.FocusIn, new GenericListener()); >- >- currentCol += 2; >- } else if (key.equals("component")) { >- // newLayout(attributesComposite, 1, name, PROPERTY); >- toolkit.createLabel(attributesComposite, name); >- componentCombo = new CCombo(attributesComposite, SWT.FLAT | SWT.NO_BACKGROUND | SWT.MULTI >- | SWT.V_SCROLL | SWT.READ_ONLY); >- toolkit.adapt(componentCombo, true, true); >- componentCombo.setFont(TEXT_FONT); >- componentCombo.setLayoutData(data); >- // componentCombo.setBackground(background); >- Set<String> s = values.keySet(); >- String[] a = s.toArray(new String[s.size()]); >- Arrays.sort(a); >- for (int i = 0; i < a.length; i++) { >- componentCombo.add(a[i]); >+ }); >+ text.addListener(SWT.FocusIn, new GenericListener()); > } >- componentCombo.select(componentCombo.indexOf(value)); >- // componentCombo.addListener(SWT.Modify, this); >- componentCombo.addSelectionListener(new ComboSelectionListener(componentCombo)); >- componentCombo.addListener(SWT.FocusIn, new GenericListener()); >- comboListenerMap.put(componentCombo, name); >- currentCol += 2; >- } else if (name.equals("Summary")) { >- // Don't show the summary here. >- continue; >- } else if (name.equals("Last Modified")) { >- // Don't show last modified here. >- continue; >- } else if (name.equals("Bug#")) { >- // Don't show bug number here >- continue; >- } else if (values.isEmpty()) { >- // newLayout(attributesComposite, 1, name, PROPERTY); >- toolkit.createLabel(attributesComposite, name); >- Composite uneditableComp = toolkit.createComposite(attributesComposite); >- GridLayout textLayout = new GridLayout(); >- textLayout.marginWidth = 1; >- uneditableComp.setLayout(textLayout); >- toolkit.createText(uneditableComp, value, SWT.READ_ONLY);// Label(attributesComposite, >- // value); >- // newLayout(attributesComposite, 1, value, >- // VALUE).addListener(SWT.FocusIn, new GenericListener()); >+ > currentCol += 2; > } > if (currentCol > attributesLayout.numColumns) { > currentCol -= attributesLayout.numColumns; > } >+ > } >- // End Populate Attributes > > // make sure that we are in the first column > if (currentCol > 1) { > while (currentCol <= attributesLayout.numColumns) { >- newLayout(attributesComposite, 1, "", PROPERTY); >+ toolkit.createLabel(attributesComposite, ""); >+ // newLayout(attributesComposite, 1, "", PROPERTY); > currentCol++; > } > } > >- // URL, Keywords, Summary Text Fields >- addUrlText(url, attributesComposite); >+ // Perhaps these should be performed in subclass eventually >+ >+ addCCList(toolkit, "", attributesComposite); >+ >+ // URL field >+ addUrlText(getReport().getAttributeValue(BugzillaReportElement.BUG_FILE_LOC), attributesComposite); > > // keywords text field (not editable) >- addKeywordsList(toolkit, keywords, attributesComposite); >- if (ccValue != null) { >- addCCList(toolkit, ccValue, attributesComposite); >- } >+ addKeywordsList(toolkit, getReport().getAttributeValue(BugzillaReportElement.KEYWORDS), attributesComposite); >+ > addSummaryText(attributesComposite); > // End URL, Keywords, Summary Text Fields > toolkit.paintBordersFor(attributesComposite); >@@ -843,9 +1037,9 @@ > urlText.addListener(SWT.KeyUp, new Listener() { > public void handleEvent(Event event) { > String sel = urlText.getText(); >- Attribute a = getBug().getAttribute("URL"); >- if (!(a.getNewValue().equals(sel))) { >- a.setNewValue(sel); >+ AbstractRepositoryReportAttribute a = getReport().getAttribute(BugzillaReportElement.BUG_FILE_LOC); >+ if (!(a.getValue().equals(sel))) { >+ a.setValue(sel); > changeDirtyStatus(true); > } > } >@@ -1187,12 +1381,12 @@ > public void saveBug() { > try { > updateBug(); >- IBugzillaBug bug = getBug(); >+ // IBugzillaBug bug = getBug(); > > final BugzillaRepositoryConnector bugzillaRepositoryClient = (BugzillaRepositoryConnector) MylarTaskListPlugin > .getRepositoryManager().getRepositoryConnector(BugzillaPlugin.REPOSITORY_KIND); > changeDirtyStatus(false); >- bugzillaRepositoryClient.saveBugReport(bug); >+ bugzillaRepositoryClient.saveBugReport((BugzillaReport) getReport()); > } catch (Exception e) { > MylarStatusHandler.fail(e, "bug save offline failed", true); > } >@@ -1336,7 +1530,7 @@ > */ > protected class GenericListener implements Listener { > public void handleEvent(Event event) { >- IBugzillaBug bug = getBug(); >+ BugzillaReport bug = (BugzillaReport) getReport(); > fireSelectionChanged(new SelectionChangedEvent(selectionProvider, new StructuredSelection( > new BugzillaReportSelection(bug.getId(), bug.getRepositoryUrl(), bug.getLabel(), false, bug > .getSummary())))); >Index: src/org/eclipse/mylar/internal/bugzilla/ui/editor/NewBugEditorInput.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/editor/NewBugEditorInput.java,v >retrieving revision 1.1 >diff -u -r1.1 NewBugEditorInput.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/editor/NewBugEditorInput.java 24 Jan 2006 19:55:14 -0000 1.1 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/editor/NewBugEditorInput.java 8 May 2006 23:07:32 -0000 >@@ -11,14 +11,14 @@ > > package org.eclipse.mylar.internal.bugzilla.ui.editor; > >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; > > /** > * The <code>IEditorInput</code> implementation for <code>NewBugEditor</code>. > */ > public class NewBugEditorInput extends AbstractBugEditorInput { > >- protected NewBugModel bug; >+ protected NewBugzillaReport bug; > > /** > * Creates a new <code>NewBugEditorInput</code>. >@@ -26,7 +26,7 @@ > * @param bug > * The bug for this editor input. > */ >- public NewBugEditorInput(NewBugModel bug) { >+ public NewBugEditorInput(NewBugzillaReport bug) { > this.bug = bug; > } > >@@ -35,7 +35,7 @@ > } > > @Override >- public NewBugModel getBug() { >+ public NewBugzillaReport getBug() { > return bug; > } > >Index: src/org/eclipse/mylar/internal/bugzilla/ui/editor/BugzillaOutlineNode.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/editor/BugzillaOutlineNode.java,v >retrieving revision 1.3 >diff -u -r1.3 BugzillaOutlineNode.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/editor/BugzillaOutlineNode.java 10 Feb 2006 04:36:34 -0000 1.3 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/editor/BugzillaOutlineNode.java 8 May 2006 23:07:31 -0000 >@@ -13,11 +13,11 @@ > import java.util.ArrayList; > import java.util.Iterator; > >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.bugzilla.core.Comment; > import org.eclipse.mylar.bugzilla.core.IBugzillaBug; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaReportSelection; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; > import org.eclipse.mylar.internal.bugzilla.ui.BugzillaImages; > import org.eclipse.swt.graphics.Image; > >@@ -196,10 +196,10 @@ > public static BugzillaOutlineNode parseBugReport(IBugzillaBug bug) { > // Choose the appropriate parsing function based on > // the type of IBugzillaBug. >- if (bug instanceof NewBugModel) { >- return parseBugReport((NewBugModel) bug); >- } else if (bug instanceof BugReport) { >- return parseBugReport((BugReport) bug); >+ if (bug instanceof NewBugzillaReport) { >+ return parseBugReport((NewBugzillaReport) bug); >+ } else if (bug instanceof BugzillaReport) { >+ return parseBugReport((BugzillaReport) bug); > } else { > return null; > } >@@ -214,7 +214,7 @@ > * The <code>NewBugModel</code> that needs parsing. > * @return The tree of <code>BugzillaOutlineNode</code>'s. > */ >- protected static BugzillaOutlineNode parseBugReport(NewBugModel bug) { >+ protected static BugzillaOutlineNode parseBugReport(NewBugzillaReport bug) { > int bugId = bug.getId(); > String bugServer = bug.getRepositoryUrl(); > Image bugImage = BugzillaImages.getImage(BugzillaImages.BUG); >@@ -241,7 +241,7 @@ > * The <code>BugReport</code> that needs parsing. > * @return The tree of <code>BugzillaOutlineNode</code>'s. > */ >- protected static BugzillaOutlineNode parseBugReport(BugReport bug) { >+ protected static BugzillaOutlineNode parseBugReport(BugzillaReport bug) { > > int bugId = bug.getId(); > String bugServer = bug.getRepositoryUrl(); >@@ -259,7 +259,8 @@ > BugzillaOutlineNode comments = null; > for (Iterator<Comment> iter = bug.getComments().iterator(); iter.hasNext();) { > Comment comment = iter.next(); >- >+ // first comment is the bug description >+ if(comment.getNumber() == 0) continue; > if (comments == null) { > comments = new BugzillaOutlineNode(bugId, bugServer, "Comments", defaultImage, comment, bug > .getSummary()); >Index: src/org/eclipse/mylar/internal/bugzilla/ui/editor/ExistingBugEditorInput.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/editor/ExistingBugEditorInput.java,v >retrieving revision 1.5 >diff -u -r1.5 ExistingBugEditorInput.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/editor/ExistingBugEditorInput.java 20 Feb 2006 19:53:48 -0000 1.5 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/editor/ExistingBugEditorInput.java 8 May 2006 23:07:32 -0000 >@@ -14,7 +14,7 @@ > > import javax.security.auth.login.LoginException; > >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; > import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin; >@@ -32,7 +32,7 @@ > > protected int bugId; > >- protected BugReport bug; >+ protected BugzillaReport bug; > > /** > * Creates a new <code>ExistingBugEditorInput</code>. >@@ -40,7 +40,7 @@ > * @param bug > * The bug for this editor input. > */ >- public ExistingBugEditorInput(BugReport bug) { >+ public ExistingBugEditorInput(BugzillaReport bug) { > this.bug = bug; > this.bugId = bug.getId(); > repository = MylarTaskListPlugin.getRepositoryManager().getRepository(BugzillaPlugin.REPOSITORY_KIND, >@@ -101,7 +101,7 @@ > } > > @Override >- public BugReport getBug() { >+ public BugzillaReport getBug() { > return bug; > } > >Index: src/org/eclipse/mylar/internal/bugzilla/ui/BugzillaUITools.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/BugzillaUITools.java,v >retrieving revision 1.4 >diff -u -r1.4 BugzillaUITools.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/BugzillaUITools.java 6 Apr 2006 04:10:30 -0000 1.4 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/BugzillaUITools.java 8 May 2006 23:07:31 -0000 >@@ -25,11 +25,11 @@ > import org.eclipse.jface.text.IRegion; > import org.eclipse.jface.text.Region; > import org.eclipse.jface.text.hyperlink.IHyperlink; >-import org.eclipse.mylar.bugzilla.core.BugReport; >+import org.eclipse.mylar.bugzilla.core.BugzillaReport; > import org.eclipse.mylar.bugzilla.core.IBugzillaBug; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; > import org.eclipse.mylar.internal.bugzilla.ui.editor.ExistingBugEditor; > import org.eclipse.mylar.internal.bugzilla.ui.editor.ExistingBugEditorInput; > import org.eclipse.mylar.internal.bugzilla.ui.editor.NewBugEditorInput; >@@ -227,14 +227,14 @@ > } > > public static void closeEditor(IWorkbenchPage page, IBugzillaBug bug) { >- if (bug instanceof NewBugModel) { >- IEditorInput input = new NewBugEditorInput((NewBugModel) bug); >+ if (bug instanceof NewBugzillaReport) { >+ IEditorInput input = new NewBugEditorInput((NewBugzillaReport) bug); > IEditorPart bugEditor = page.findEditor(input); > if (bugEditor != null) { > page.closeEditor(bugEditor, false); > } >- } else if (bug instanceof BugReport) { >- IEditorInput input = new ExistingBugEditorInput((BugReport) bug); >+ } else if (bug instanceof BugzillaReport) { >+ IEditorInput input = new ExistingBugEditorInput((BugzillaReport) bug); > IEditorPart bugEditor = page.findEditor(input); > if (bugEditor != null) { > page.closeEditor(bugEditor, false); >Index: src/org/eclipse/mylar/internal/bugzilla/ui/wizard/AbstractBugWizard.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/wizard/AbstractBugWizard.java,v >retrieving revision 1.10 >diff -u -r1.10 AbstractBugWizard.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/wizard/AbstractBugWizard.java 28 Apr 2006 20:41:38 -0000 1.10 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/wizard/AbstractBugWizard.java 8 May 2006 23:07:32 -0000 >@@ -23,7 +23,7 @@ > import org.eclipse.mylar.internal.bugzilla.core.BugzillaException; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; > import org.eclipse.mylar.internal.bugzilla.core.PossibleBugzillaFailureException; > import org.eclipse.mylar.internal.bugzilla.ui.BugzillaUiPlugin; > import org.eclipse.mylar.internal.bugzilla.ui.WebBrowserDialog; >@@ -54,7 +54,7 @@ > protected boolean fromDialog = false; > > /** The model used to store all of the data for the wizard */ >- protected NewBugModel model; >+ protected NewBugzillaReport model; > > /** > * Flag to indicate if the wizard can be completed based on the attributes >@@ -70,7 +70,7 @@ > public AbstractBugWizard(TaskRepository repository) { > super(); > this.repository = repository; >- model = new NewBugModel(); >+ model = new NewBugzillaReport(repository.getUrl()); > id = null; // Since there is no bug posted yet. > super.setDefaultPageImageDescriptor(BugzillaUiPlugin.imageDescriptorFromPlugin( > "org.eclipse.mylar.internal.bugzilla.ui", "icons/wizban/bug-wizard.gif")); >Index: src/org/eclipse/mylar/internal/bugzilla/ui/wizard/AbstractBugzillaWizardPage.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/wizard/AbstractBugzillaWizardPage.java,v >retrieving revision 1.9 >diff -u -r1.9 AbstractBugzillaWizardPage.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/wizard/AbstractBugzillaWizardPage.java 28 Apr 2006 20:41:38 -0000 1.9 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/wizard/AbstractBugzillaWizardPage.java 8 May 2006 23:07:32 -0000 >@@ -20,9 +20,9 @@ > import org.eclipse.core.runtime.Status; > import org.eclipse.jface.wizard.IWizardPage; > import org.eclipse.jface.wizard.WizardPage; >-import org.eclipse.mylar.bugzilla.core.Attribute; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >-import org.eclipse.mylar.internal.bugzilla.core.internal.BugReportElement; >+import org.eclipse.mylar.bugzilla.core.AbstractRepositoryReportAttribute; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; >+import org.eclipse.mylar.internal.bugzilla.core.internal.BugzillaReportElement; > import org.eclipse.mylar.internal.bugzilla.ui.editor.AbstractBugEditor; > import org.eclipse.mylar.internal.core.util.MylarStatusHandler; > import org.eclipse.swt.SWT; >@@ -303,51 +303,53 @@ > public void saveDataToModel() { > // get the model that we are using > AbstractBugWizard wizard = (AbstractBugWizard) getWizard(); >- NewBugModel nbm = wizard.model; >+ NewBugzillaReport nbm = wizard.model; > > nbm.setDescription(descriptionText.getText()); > nbm.setSummary(summaryText.getText()); > > // go through each of the attributes and sync their values with the > // combo boxes >- for (Iterator<Attribute> it = nbm.getAttributes().iterator(); it.hasNext();) { >- Attribute attribute = it.next(); >+ for (Iterator<AbstractRepositoryReportAttribute> it = nbm.getAttributes().iterator(); it.hasNext();) { >+ AbstractRepositoryReportAttribute attribute = it.next(); > String key = attribute.getName(); > Map<String, String> values = attribute.getOptionValues(); > > try { > if (values == null) > values = new HashMap<String, String>(); >- if (key.equals(BugReportElement.OP_SYS.toString())) { >+ if (key.equals(BugzillaReportElement.OP_SYS.toString())) { > String os = oSCombo.getItem(oSCombo.getSelectionIndex()); > attribute.setValue(os); >- } else if (key.equals(BugReportElement.VERSION.toString())) { >+ } else if (key.equals(BugzillaReportElement.VERSION.toString())) { > String version = versionCombo.getItem(versionCombo.getSelectionIndex()); > attribute.setValue(version); >- } else if (key.equals(BugReportElement.BUG_SEVERITY.toString())) { >+ } else if (key.equals(BugzillaReportElement.BUG_SEVERITY.toString())) { > String severity = severityCombo.getItem(severityCombo.getSelectionIndex()); > attribute.setValue(severity); >- } else if (key.equals(BugReportElement.REP_PLATFORM.toString())) { >+ } else if (key.equals(BugzillaReportElement.REP_PLATFORM.toString())) { > String platform = platformCombo.getItem(platformCombo.getSelectionIndex()); > attribute.setValue(platform); >- } else if (key.equals(BugReportElement.TARGET_MILESTONE.toString())) { >+ } else if (key.equals(BugzillaReportElement.TARGET_MILESTONE.toString())) { > int index = milestoneCombo.getSelectionIndex(); > if(index >= 0) { > String milestone = milestoneCombo.getItem(milestoneCombo.getSelectionIndex()); > attribute.setValue(milestone); > } >- } else if (key.equals(BugReportElement.COMPONENT.toString())) { >+ } else if (key.equals(BugzillaReportElement.COMPONENT.toString())) { > String component = componentCombo.getItem(componentCombo.getSelectionIndex()); > attribute.setValue(component); >- } else if (key.equals(BugReportElement.PRIORITY.toString())) { >+ } else if (key.equals(BugzillaReportElement.PRIORITY.toString())) { > String priority = priorityCombo.getItem(priorityCombo.getSelectionIndex()); > attribute.setValue(priority); >- } else if (key.equals(BugReportElement.BUG_FILE_LOC.toString())) { >- String url = urlText.getText(); >- if (url.equalsIgnoreCase("http://")) >- url = ""; >- attribute.setValue(url); >- } else if (key.equals(BugReportElement.ASSIGNED_TO.toString())) { >+ } else if (key.equals(BugzillaReportElement.BUG_FILE_LOC.toString())) { >+ if (urlText != null) { >+ String url = urlText.getText(); >+ if (url.equalsIgnoreCase("http://")) >+ url = ""; >+ attribute.setValue(url); >+ } >+ } else if (key.equals(BugzillaReportElement.ASSIGNED_TO.toString())) { > String assignTo = assignedToText.getText(); > attribute.setValue(assignTo); > } else { >@@ -379,7 +381,7 @@ > > // get the model for the new bug > AbstractBugWizard wizard = (AbstractBugWizard) getWizard(); >- NewBugModel nbm = wizard.model; >+ NewBugzillaReport nbm = wizard.model; > > // Set the current platform and OS on the model > setPlatformOptions(nbm); >@@ -414,9 +416,9 @@ > newLayout(attributesComposite, 1, nbm.getProduct(), VALUE); > > // Populate Attributes >- for (Iterator<Attribute> it = nbm.getAttributes().iterator(); it.hasNext();) { >- Attribute attribute = it.next(); >- String key = attribute.getParameterName(); >+ for (Iterator<AbstractRepositoryReportAttribute> it = nbm.getAttributes().iterator(); it.hasNext();) { >+ AbstractRepositoryReportAttribute attribute = it.next(); >+ String key = attribute.getID(); > String name = attribute.getName(); > String value = checkText(attribute.getValue()); > Map<String, String> values = attribute.getOptionValues(); >@@ -436,7 +438,7 @@ > data.horizontalIndent = HORZ_INDENT; > data.widthHint = 150; > // create and populate the combo fields for the attributes >- if (key.equals(BugReportElement.OP_SYS.getKeyString())) { >+ if (key.equals(BugzillaReportElement.OP_SYS.getKeyString())) { > newLayout(attributesComposite, 1, name, PROPERTY); > oSCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY); > >@@ -451,7 +453,7 @@ > index = 0; > oSCombo.select(index); > oSCombo.addListener(SWT.Modify, this); >- } else if (key.equals(BugReportElement.VERSION.getKeyString())) { >+ } else if (key.equals(BugzillaReportElement.VERSION.getKeyString())) { > newLayout(attributesComposite, 1, name, PROPERTY); > > versionCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL >@@ -468,7 +470,7 @@ > index = 0; > versionCombo.select(index); > versionCombo.addListener(SWT.Modify, this); >- } else if (key.equals(BugReportElement.BUG_SEVERITY.getKeyString())) { >+ } else if (key.equals(BugzillaReportElement.BUG_SEVERITY.getKeyString())) { > newLayout(attributesComposite, 1, name, PROPERTY); > severityCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL > | SWT.READ_ONLY); >@@ -485,7 +487,7 @@ > severityCombo.select(index); > severityCombo.addListener(SWT.Modify, this); > >- } else if (key.equals(BugReportElement.REP_PLATFORM.getKeyString())) { >+ } else if (key.equals(BugzillaReportElement.REP_PLATFORM.getKeyString())) { > newLayout(attributesComposite, 1, name, PROPERTY); > platformCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL > | SWT.READ_ONLY); >@@ -501,7 +503,7 @@ > index = 0; > platformCombo.select(index); > platformCombo.addListener(SWT.Modify, this); >- } else if (key.equals(BugReportElement.TARGET_MILESTONE.getKeyString())) { >+ } else if (key.equals(BugzillaReportElement.TARGET_MILESTONE.getKeyString())) { > newLayout(attributesComposite, 1, name, PROPERTY); > milestoneCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL > | SWT.READ_ONLY); >@@ -518,7 +520,7 @@ > milestoneCombo.addListener(SWT.Modify, this); > //if(s.isEmpty()) milestoneCombo.setEnabled(false); > mileExist = true; >- } else if (key.equals(BugReportElement.COMPONENT.getKeyString())) { >+ } else if (key.equals(BugzillaReportElement.COMPONENT.getKeyString())) { > newLayout(attributesComposite, 1, name, PROPERTY); > componentCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL > | SWT.READ_ONLY); >@@ -534,7 +536,7 @@ > index = 0; > componentCombo.select(index); > componentCombo.addListener(SWT.Modify, this); >- } else if (key.equals(BugReportElement.PRIORITY.getKeyString())) { >+ } else if (key.equals(BugzillaReportElement.PRIORITY.getKeyString())) { > newLayout(attributesComposite, 1, name, PROPERTY); > priorityCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL > | SWT.READ_ONLY); >@@ -551,7 +553,7 @@ > priorityCombo.select(index); > priorityCombo.addListener(SWT.Modify, this); > priExist = true; >- } else if (key.equals(BugReportElement.BUG_FILE_LOC.getKeyString())) { >+ } else if (key.equals(BugzillaReportElement.BUG_FILE_LOC.getKeyString())) { > url = value; > } else { > // do nothing if it isn't a standard value to change >@@ -573,7 +575,7 @@ > > GridData urlTextData; > if (url != null) { >- newLayout(textComposite, 1, BugReportElement.BUG_FILE_LOC.toString(), PROPERTY); >+ newLayout(textComposite, 1, BugzillaReportElement.BUG_FILE_LOC.toString(), PROPERTY); > urlText = new Text(textComposite, SWT.BORDER | SWT.SINGLE | SWT.WRAP); > urlTextData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); > >@@ -585,7 +587,7 @@ > } > > GridData summaryTextData; >- newLayout(textComposite, 1, BugReportElement.ASSIGNED_TO.toString(), PROPERTY); >+ newLayout(textComposite, 1, BugzillaReportElement.ASSIGNED_TO.toString(), PROPERTY); > Label l = new Label(textComposite, SWT.NONE); > l.setText("(if email is incorrect submit will not proceed)"); > summaryTextData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >@@ -600,7 +602,7 @@ > assignedToText.setText(""); > > // add the summary text field >- newLayout(textComposite, 1, BugReportElement.SHORT_DESC.toString(), PROPERTY); >+ newLayout(textComposite, 1, BugzillaReportElement.SHORT_DESC.toString(), PROPERTY); > summaryText = new Text(textComposite, SWT.BORDER | SWT.SINGLE | SWT.WRAP); > summaryTextData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); > >@@ -693,7 +695,7 @@ > * @param newBugModel > * The bug to set the options for > */ >- public void setPlatformOptions(NewBugModel newBugModel) { >+ public void setPlatformOptions(NewBugzillaReport newBugModel) { > try { > // A Map from Java's OS and Platform to Buzilla's > Map<String, String> java2buzillaOSMap = new HashMap<String, String>(); >@@ -712,12 +714,12 @@ > java2buzillaOSMap.put("macosx", "MacOS X"); > java2buzillaOSMap.put("qnx", "QNX-Photon"); > java2buzillaOSMap.put("solaris", "Solaris"); >- java2buzillaOSMap.put("win32", "Windows All"); >+ java2buzillaOSMap.put("win32", "Windows"); > > // Get OS Lookup Map > // Check that the result is in Values, if it is not, set it to other >- Attribute opSysAttribute = newBugModel.getAttribute(BugReportElement.OP_SYS.toString()); >- Attribute platformAttribute = newBugModel.getAttribute(BugReportElement.REP_PLATFORM.toString()); >+ AbstractRepositoryReportAttribute opSysAttribute = newBugModel.getAttribute(BugzillaReportElement.OP_SYS); >+ AbstractRepositoryReportAttribute platformAttribute = newBugModel.getAttribute(BugzillaReportElement.REP_PLATFORM); > > String OS = Platform.getOS(); > String platform = Platform.getOSArch(); >Index: src/org/eclipse/mylar/internal/bugzilla/ui/wizard/BugzillaProductPage.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/wizard/BugzillaProductPage.java,v >retrieving revision 1.14 >diff -u -r1.14 BugzillaProductPage.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/wizard/BugzillaProductPage.java 27 Apr 2006 00:15:21 -0000 1.14 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/wizard/BugzillaProductPage.java 8 May 2006 23:07:32 -0000 >@@ -26,7 +26,7 @@ > import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; > import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; > import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >-import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; > import org.eclipse.mylar.internal.bugzilla.ui.BugzillaUiPlugin; > import org.eclipse.mylar.internal.tasklist.ui.views.TaskRepositoriesView; > import org.eclipse.mylar.provisional.tasklist.TaskRepository; >@@ -87,7 +87,7 @@ > this.bugWizard = bugWiz; > this.repository = repository; > setImageDescriptor(BugzillaUiPlugin.imageDescriptorFromPlugin("org.eclipse.mylar.bugzilla.ui", >- "icons/wizban/bug-wizard.gif")); >+ "icons/wizban/bug-wizard.gif")); > } > > protected ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(BugzillaPlugin.getDefault() >@@ -131,10 +131,8 @@ > "Bugzilla could not log you in to get the information you requested since login name or password is incorrect.\nPlease check your settings in the bugzilla preferences. "); > BugzillaPlugin.log(exception); > } catch (IOException exception) { >- MessageDialog >- .openError( >- null, >- "Connection Error","\nPlease check your settings in the bugzilla preferences. "); >+ MessageDialog.openError(null, "Connection Error", >+ "\nPlease check your settings in the bugzilla preferences. "); > } finally { > monitor.done(); > monitorDialog.close(); >@@ -159,12 +157,12 @@ > bugWizard.model.setParsedProductsStatus(true); > > } catch (Exception e) { >- bugWizard.model.setConnected(false); >+ bugWizard.model.setConnected(false); > PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { >- public void run() { >- MessageDialog >- .openError(Display.getDefault().getActiveShell(), NEW_BUGZILLA_TASK_ERROR_TITLE, >- "Unable to get products. Ensure proper repository configuration in "+TaskRepositoriesView.NAME+"."); >+ public void run() { >+ MessageDialog.openError(Display.getDefault().getActiveShell(), NEW_BUGZILLA_TASK_ERROR_TITLE, >+ "Unable to get products. Ensure proper repository configuration in " >+ + TaskRepositoriesView.NAME + "."); > } > }); > } >@@ -204,29 +202,24 @@ > // save the product information to the model > saveDataToModel(); > NewBugzillaReportWizard wizard = (NewBugzillaReportWizard) getWizard(); >- NewBugModel model = wizard.model; >+ NewBugzillaReport model = wizard.model; > > // try to get the attributes from the bugzilla server > try { >- //if (prevProduct != null && !prevProduct.equals(model.getProduct())) { >- //!model.hasParsedAttributes() || >- String serverUrl = repository.getUrl(); >-// if (model.isConnected()) { >-// BugzillaRepositoryUtil.setupNewBugAttributes(serverUrl, model, false); >-// } else { >- >- BugzillaRepositoryUtil.setupBugAttributes(serverUrl, model); >-// } >+ if (!model.hasParsedAttributes()) { >+ BugzillaRepositoryUtil.setupNewBugAttributes(repository, model); > model.setParsedAttributesStatus(true); >- if (prevProduct == null) { >- bugWizard.setAttributePage(new WizardAttributesPage(workbench)); >- bugWizard.addPage(bugWizard.getAttributePage()); >- } else { >- // selected product has changed >- // will createControl again with new attributes in model >- bugWizard.getAttributePage().setControl(null); >- } >- //} >+ } >+ >+ if (prevProduct == null) { >+ bugWizard.setAttributePage(new WizardAttributesPage(workbench)); >+ bugWizard.addPage(bugWizard.getAttributePage()); >+ } else { >+ // selected product has changed >+ // will createControl again with new attributes in model >+ bugWizard.getAttributePage().setControl(null); >+ } >+ // } > } catch (final Exception e) { > e.printStackTrace(); > PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { >@@ -235,9 +228,12 @@ > .getLocalizedMessage() > + " Ensure proper repository configuration in " + TaskRepositoriesView.NAME + "."); > } >- }); >-// MylarStatusHandler.fail(e, e.getLocalizedMessage()+" Ensure proper repository configuration in "+TaskRepositoriesView.NAME+".", true); >-// BugzillaPlugin.getDefault().logAndShowExceptionDetailsDialog(e, "occurred.", "Bugzilla Error"); >+ }); >+ // MylarStatusHandler.fail(e, e.getLocalizedMessage()+" Ensure >+ // proper repository configuration in >+ // "+TaskRepositoriesView.NAME+".", true); >+ // BugzillaPlugin.getDefault().logAndShowExceptionDetailsDialog(e, >+ // "occurred.", "Bugzilla Error"); > } > return super.getNextPage(); > } >@@ -247,7 +243,7 @@ > */ > private void saveDataToModel() { > // Gets the model >- NewBugModel model = bugWizard.model; >+ NewBugzillaReport model = bugWizard.model; > > prevProduct = model.getProduct(); > model.setProduct((listBox.getSelection())[0]);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 136219
:
39378
|
39381
|
39429
|
39484
|
39498
|
39599
|
39615
|
39833
|
39835
|
40093
| 40670 |
40671