Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 259434

Summary: the owner name and created date of the attachment file of the localized Bugzilla are not displayed.
Product: z_Archived Reporter: Hiroyuki <hiroyuki.inaba>
Component: MylynAssignee: Hiroyuki <hiroyuki.inaba>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P2 CC: robert.elves
Version: dev   
Target Milestone: 3.1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
bugzilla.core.patch
none
updated patch none

Description Hiroyuki CLA 2008-12-20 03:40:47 EST
The comment on appending is judged directly. 
Therefore, when the international resource is displayed, the comment cannot be correctly judged. 

org.eclipse.mylyn.bugzilla.core
/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java

private static final String COMMENT_ATTACHMENT_STRING = Messages.SaxMultiBugReportContentHandler_CREATED_AN_ATTACHEMENT_ID;

/** determines attachment id from comment */
private void parseAttachment(TaskCommentMapper comment) {

		String attachmentID = ""; //$NON-NLS-1$
		String commentText = comment.getText();
		if (commentText.startsWith(COMMENT_ATTACHMENT_STRING)) {

SaxMultiBugReportContentHandler_CREATED_AN_ATTACHEMENT_ID=Created an attachment (id=

If the resource was internationalized, "Created an attachment" is translated.
CommentText.startsWith() always becomes False. 

It is necessary to judge by combining " (id =", figure and ")".
Comment 1 Hiroyuki CLA 2008-12-20 03:43:58 EST
For instance, it is possible to correct it by adding the following processing. 

	private static final String ID_STRING_BEGIN = " (id="; //$NON-NLS-1$
	private static final String ID_STRING_END = ")"; //$NON-NLS-1$

		private void parseAttachment(TaskCommentMapper comment) {

		String attachmentID = ""; //$NON-NLS-1$
		String commentText = comment.getText();
		if (commentText.startsWith(COMMENT_ATTACHMENT_STRING)) {
			int endIndex = commentText.indexOf(")"); //$NON-NLS-1$
			if (endIndex > 0 && endIndex < commentText.length()) {
				attachmentID = commentText.substring(COMMENT_ATTACHMENT_STRING.length(), endIndex);
				if (!attachmentID.equals("")) { //$NON-NLS-1$
					attachIdToComment.put(attachmentID, comment);
				}
			}
		}

		// Additional codes
		else {
			int startIndex = commentText.indexOf(ID_STRING_BEGIN);
			if (startIndex > 0) {
				int endIndex = commentText.indexOf(ID_STRING_END, startIndex);
				if (endIndex > 0) {
					startIndex += ID_STRING_BEGIN.length();
					int p = startIndex;
					while (p < endIndex) {
						char c = commentText.charAt(p);
						if (c < '0' || c > '9') {
							break;
						}
						p++;
					}
					if (p == endIndex) {
						attachmentID = commentText.substring(startIndex, endIndex);
						if (!attachmentID.equals("")) { //$NON-NLS-1$
							attachIdToComment.put(attachmentID, comment);
						}
					}
				}
			}
		}

	}
	
Comment 2 Hiroyuki CLA 2009-01-02 03:12:47 EST
The mistake was found in the code.  A correct code is the following. 

int firstDelimiter = commentText.indexOf("\n"); //$NON-NLS-1$
if (firstDelimiter < 0) {
	firstDelimiter = commentText.length();
}
int startIndex = commentText.indexOf(ID_STRING_BEGIN);
if (startIndex > 0 && startIndex < firstDelimiter) {
	int endIndex = commentText.indexOf(ID_STRING_END, startIndex);
	if (endIndex > 0 && endIndex < firstDelimiter) {
		startIndex += ID_STRING_BEGIN.length();
		int p = startIndex;
		while (p < endIndex) {
			char c = commentText.charAt(p);
			if (c < '0' || c > '9') {
				break;
			}
			p++;
		}
		if (p == endIndex) {
			attachmentID = commentText.substring(startIndex, endIndex);
			if (!attachmentID.equals("")) { //$NON-NLS-1$
				attachIdToComment.put(attachmentID, comment);
			}
		}
	}
}
Comment 3 Hiroyuki CLA 2009-01-08 05:56:16 EST
The owner name and created date of the attachement file of the localized Bugzilla  are not displayed. 

The owner name and created date are retrieve from the attached comment. 
The localized string was used by this processing. 
Therefore, the owner name and created date were not retrieved. 

I think the expectation of English string to be a mistake.
Comment 4 Robert Elves CLA 2009-01-14 19:56:08 EST
Hiroyuki, would you be willing to create a patch and attach to this bug report?
Comment 5 Hiroyuki CLA 2009-01-15 09:10:34 EST
Created attachment 122679 [details]
bugzilla.core.patch
Comment 6 Robert Elves CLA 2009-02-02 23:48:55 EST
Patch applied, ip log updated.
Comment 7 Robert Elves CLA 2009-02-02 23:49:23 EST
Created attachment 124505 [details]
updated patch
Comment 8 Robert Elves CLA 2009-02-02 23:49:43 EST
Marking resolved.