It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira 7 -> 8 componentmanager problem

Hello All,

Please help me, we've just upgraded from Jira 7 to Jira 8.

1 of our scripts failed. ComponentManager no longer usable. Could you help me how can I revive the script?

ChangeHistoryManager changeHistoryManager = (ChangeHistoryManager)ComponentManager.getComponentInstanceOfType(ChangeHistoryManager.class);

The error message: [Static type checking] - The variable [ComponentManager] is undeclared.

Screenshot_288.png

Thank you!

 

 

The full script

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.changehistory.ChangeHistory;
import com.atlassian.jira.issue.changehistory.ChangeHistoryManager;
import com.atlassian.jira.issue.status.Status;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.ofbiz.core.entity.GenericValue;

Logger log = LoggerFactory.getLogger("Previous Status Field");

log.debug("Issue " + issue.getKey());
ChangeHistoryManager changeHistoryManager = (ChangeHistoryManager)ComponentManager.getComponentInstanceOfType(ChangeHistoryManager.class);
List changeHistory = changeHistoryManager.getChangeHistories(issue);
for (int i = changeHistory.size() - 1; i >= 0; i--)
{
ChangeHistory changeHistoryItem = (ChangeHistory)changeHistory.get(i);

List changeItemBeans = changeHistoryItem.getChangeItems();
Iterator it = changeItemBeans.iterator();
while (it.hasNext())
{
GenericValue change = (GenericValue)it.next();
String changedField = change.getString("field");
if (changedField.equalsIgnoreCase("status"))
{
String oldStatus = change.getString("oldstring");
return oldStatus;
}
}
}
return null;

1 answer

Hello, 

use ComponentAccessor instead

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Keep your team in the loop with Team @mentions in Jira Software!

Hi everyone! My name is Jenny, a Product Manager at Atlassian. After launching Team @mentions in Confluence, we heard a lot of positive feedback from customers that they love how easy it is to @men...

555 views 6 18
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you