Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How is the attachment storage path constructed in JIRA?

Kristofer Hansson Aspman _Riada_
Contributor
April 7, 2016

Hi!

I am wondering about the attachment storage path for JIRA. On a server that I am running, the structure of the attachments directory (/var/atlassian/application-data/jira/data/attachments/) looks like this:

`-- JSDT
    `-- 10000
        `-- JSDT-2
            |-- 10100
            `-- thumbs
                `-- _thumb_10100.png

I am currently writing a groovy script in which I need to determine the path to an attachment. In answers to questions such as https://answers.atlassian.com/questions/297697, PathUtils.joinPaths() is used to construct the path. However, it does not seem to add the "10000"-directory seen above. My questions related to this are:

  • Why do I have that directory? I.e. has there been a change to the directory structure since the answer to the above linked question was written? I am running JIRA Software 7.1.2 (with JSD) and can't really remember how it looked before.
  • Where does the number 10000 come from? When is a "20000"-directory added? What is the logic behind it and its relation to the attachment IDs.
  • Are there any methods that can be used to access this?

I bet I am missing something trivial, but what I see is a bit inconsistent with what I've found when looking around answers and documentation.

 

7 answers

1 accepted

3 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 9, 2013

It's hard to read that without adding the proper code formatting.

Your code looks ok. It could be written more idiomatically, but looks like it will work.

I might rewrite the last line like so:

! ['groupA', 'groupB'].any {groupManager.isUserInGroup(issue.assignee?.name, it)}

Błażej O_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 9, 2013

Thanks for the help. I added the code and it works like a charm :)

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 9, 2013

no worries... small suggestion above (untested).

Błażej O_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 9, 2013

Cool, looks far better and clean :)

1 vote
Bhushan Nagaraj
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 8, 2013

Hi Blazej,

Haven't tried this but since it is groovy I am pretty sure you could do something like this.

def groupManager = ComponentAccessor.getGroupManager()
if(groupManager.getGroupNamesForUser(issue.assignee).contains("Administrator"))

Let me know if this worked for you.

Bhushan Nagaraj's Visual Thumbprint

Błażej O_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 9, 2013

But isn't this the code fo checking if user IS in group? I were looking for something exactly opposite :)

0 votes
Ritu Garg
March 3, 2014

I am new to use Groovy Scrip Runner. I want to implement 'User Not In Group' condition.

Please tell we how can I create custom condition that can be applyed on any workflow transition and that can work similer to the in built condition 'User Is In Group'.

But not able to link it with workflow and not clear how to use these written script. Please help me.

0 votes
Ritu Garg
March 3, 2014

I am new to use Groovy Scrip Runner. I want to implement 'User Not In Group' condition.

Please tell we how can I create custom condition that can be applyed on any workflow transition and that can work similer to the in built condition 'User Is In Group'

0 votes
Błażej O_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 9, 2013

Damn, Script Runner condition won't allow me to group conditions. Can I use such structure to check if user is not in ANY fo the groups?:

import com.atlassian.jira.component.ComponentAccessor

def groupManager = ComponentAccessor.getGroupManager()

!((groupManager.isUserInGroup(issue.assignee?.name, 'groupnameA'))||(groupManager.isUserInGroup(issue.assignee?.name, 'groupnameB')))

Please, forgive me such noobish questions, I simply don't know groovy nor java, so I'm kinda like blindman trying to complete sudoku :)

0 votes
Błażej O_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 9, 2013

No no, I was just not sure if I placed "!" properly and afraid if it won't corrupt anything :)

Thanks for the opinion, I can now go and test it out :)

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 8, 2013

Looks fine to me. Are you saying it doesn't work?

Suggest an answer

Log in or Sign up to answer