Hi,
what is the best way to monitor file attach action? There is nothing like EventType.ISSUE_FILEATTACH for listener implementation. I need to detect actions, when user add new file attachments and execute own post processing methods.
Is the correct way to do this by servlet-filter plugin module on action AttachFile?
Or it is better catch ISSUE_UPDATED_ID event and check issue change log event if contans change item with field "Attachment", than get file ID according "newvalue" in change log by attachment manager.
List<GenericValue> changeItems = issueEvent.getChangeLog().getRelated("ChildChangeItem"); for (GenericValue changeItem : changeItems) {
if (((String)changeItem.get("fieldtype")).equalsIgnoreCase("JIRA") && ((String)changeItem.get("field")).equalsIgnoreCase("Attachment")) { String id = changeItem.get("newvalue").toString(); Attachment attachment = ComponentAccessor.getAttachmentManager().getAttachment(Long.valueOf(id)); } }
In the second case, how can I get attachment comment (there are no method) and attachment file content?
Community moderators have prevented the ability to post new answers.
Given an event you can see if attachments have been added using the following code:
List changeItems = event.getChangeLog()?.getRelated("ChildChangeItem") changeItems.each {GenericValue gv -> if (gv["field"] == "Attachment" && gv["newvalue"]) { attachmentIds.add(gv["newvalue"]) } }
treat it as pseudocode if you like.
Then...
attachmentIds.each {attachmentId -> Attachment attachment = issue.attachments.find {Attachment attachment -> attachment.id == new Long(attachmentId) } File attFile = AttachmentUtils.getAttachmentFile(attachment)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Jamie, exactly the same solution as my.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I found this thread, but I think that extends AttachFile is not the best solution. How can I used new Action in listener? I dont want to overwrite AttachFile class (to do this this must be plugin v1). Can you help with get file content and attachment comment? What manager, servoce or helper class should I use?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
File f = AttachmentUtils.getAttachmentFile(attachment);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
dont know how to get the contents of the file attached . an attachment can be a jar , a jpg file , etc .. what you want to do after you get the content of the attachment ? i am not sure but extending actions also work for ver 2 plugins .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Comment comment = issueEvent.getComment();
Im looking comment on the attachment, but it is associated with event :)
2Mizan: Im working on synchronization adapter JIRA vs. some another helpdesk system and I need detect some basic events like create/edit issue, add comment, attachment, ... than use customer WS interface and populate JIRA changes (including file content).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.