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

This widget could not be displayed.
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
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

511 views 3 18
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