Forums

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

MockApplicationUser

Jan Lichter December 23, 2015

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 votes
Vasiliy Zverev
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 Leaders.
December 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
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 Leaders.
December 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
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 Leaders.
December 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

Jan Lichter December 28, 2015

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.

Vasiliy Zverev
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 Leaders.
December 28, 2015

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events