MockApplicationUser

Hey guys,


I'm trying to get a service running that automatically sets Jira users to inactive state after not logging in for a while. According to some examples, I can use the class "MockApplicationUser" (extends DelegatingApplicationUser) to achieve this. But, no matter what I try, I can't create an instance of this class. I'm not even able to import that type ("can not be resolved", also no auto suggestion). It's base class ("DelegatingApplicationUser") is no problem, I can import and create an object of it.
It seems as it where not part of the sdk at all, but it's described as a public class in the apidocs.


I tried to
* updated the atlassian-plugin-sdk from 5.0.13 to 6.2.2
* cleaned the maven installation and re-downloaded all the stuff
* refreshed the eclipse project (mvn eclipse:eclipse + refresh in eclipse)


Am I missing a dependency in my pom.xml? I've included jira-api, jira-core (and some others), shouldn't that be enough?

Any help is appreciated! I'll provide more information of course, if necessary.

Regards, Jan

1 answer

0 vote
Vasiliy Zverev Community Champion Dec 23, 2015

Try this code to make a loop ove all users:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.UserPropertyManager
import com.atlassian.jira.user.util.UserManager
UserManager userManager = ComponentAccessor.getUserManager();
UserPropertyManager userPropertyManager = ComponentAccessor.getUserPropertyManager();
for(ApplicationUser appUser: userManager.getAllApplicationUsers() ){

}

I cold not find any api to get last interance date, the only solution - use SQL:https://confluence.atlassian.com/display/JIRAKB/Retrieve+last+login+dates+for+users+from+the+database

Vasiliy Zverev Community Champion Dec 23, 2015

I would recommend to try ScriptRunner plugin to test scripts (free for JIRA6). This plugin allowes to run scripts from console with out creating a plugin. When you will have a working script you can conver it to a plugin.

Vasiliy Zverev Community Champion Dec 23, 2015

Here is my SQL to get last logined users:declare @startDate datetime = '1970-1-1'; Select cwd_user.display_name as 'user name' -- , cwd_user_attributes.* , CAST( dateaDD(SECOND, CAST(cwd_user_attributes.attribute_value as bigint)/1000, @startDate ) as DATE) as 'last login date' from cwd_user join cwd_user_attributes on cwd_user.ID = cwd_user_attributes.user_id where cwd_user_attributes.attribute_name = 'login.lastLoginMillis' -- and cwd_user.email_address = 'vzverev@phosagro.ru' order by CAST(cwd_user_attributes.attribute_value as bigint) asc

Hi, thanks for your reply. But querying the users is not the point, I need a way to set those users inactive using Java. This class "MockApplicationUser" I mentioned above would be suitable, but I can't use it somehow.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

110 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you