Forums

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

ComponentAccessor.getComponent(ManageableOptionType.class) fails for jira 7.12.x

Pasan Uluwatta
Contributor
September 21, 2018

In jira 7.2.2 we were using following code section inside our rest plugin module to change the issue type scheme of the project, but it seems jira 7.12.x no longer support loading ManageableOptionType component

Code Section :

Long newIssueTypeSchemeId;
try {
newIssueTypeSchemeId = Long.parseLong(issueTypeSchemeBean.getId().trim());
} catch (NumberFormatException e) {
return Response.status(Response.Status.BAD_REQUEST)
.entity(new ErrorEntity(ErrorEntity.ErrorReason.ILLEGAL_ARGUMENT,
"It seems input scheme id cannot parse to a long value")).build();
}

log.info("Set issue type scheme function from sample.jira.plugin executed");
FieldConfigSchemeManager fieldConfigSchemeManager = ComponentAccessor.getFieldConfigSchemeManager();
ProjectManager projectManager = ComponentAccessor.getProjectManager();

FieldConfigScheme fieldConfigScheme = fieldConfigSchemeManager.getFieldConfigScheme(newIssueTypeSchemeId);
Project project = projectManager.getProjectObjByKey(projectKey);

if (fieldConfigScheme == null) {
return Response.status(Response.Status.BAD_REQUEST)
.entity(new ErrorEntity(ErrorEntity.ErrorReason.ILLEGAL_ARGUMENT,
"No issue type scheme found for id : " + newIssueTypeSchemeId)).build();
}
if (project == null) {
return Response.status(Response.Status.BAD_REQUEST)
.entity(new ErrorEntity(ErrorEntity.ErrorReason.ILLEGAL_ARGUMENT,
"No project found for key : " + projectKey)).build();
}

//get already associated projects and add ours to that list and update
List<Project> alreadyAssociatedProjects = new ArrayList<Project>();
alreadyAssociatedProjects.addAll(fieldConfigScheme.getAssociatedProjectObjects());
alreadyAssociatedProjects.add(project);

Long[] projectIds = new Long[alreadyAssociatedProjects.size()];
int count = 0;
for (Project iteredProject : alreadyAssociatedProjects) {
projectIds[count++] = iteredProject.getId();
}
List<JiraContextNode> contexts = CustomFieldUtils.buildJiraIssueContexts(false, projectIds, projectManager);

ManageableOptionType manageableOptionType = ComponentAccessor.getComponent(ManageableOptionType.class);
FieldManager fieldManager = ComponentAccessor.getFieldManager();
ConfigurableField configurableField = fieldManager.getConfigurableField(manageableOptionType.getFieldId());

//Remove the existing association
fieldConfigSchemeManager.removeSchemeAssociation(contexts, configurableField);

fieldConfigSchemeManager.updateFieldConfigScheme(fieldConfigScheme, contexts, configurableField);
log.info(projectKey + " IssueTypeScheme changed to id : " + issueTypeSchemeBean.getId());
return Response.ok(new SchemeBean(String.valueOf(fieldConfigScheme.getId()), fieldConfigScheme.getName(),
fieldConfigScheme.getDescription())).build();

 

Exception :

ExceptionMapper] Uncaught exception thrown by REST service: Unable to resolve component: interface com.atlassian.jira.web.action.admin.issuetypes.ManageableOptionType
[INFO] [talledLocalContainer] java.lang.IllegalStateException: Unable to resolve component: interface com.atlassian.jira.web.action.admin.issuetypes.ManageableOptionType
[INFO] [talledLocalContainer] at com.atlassian.jira.component.ComponentAccessorWorker.getComponent(ComponentAccessorWorker.java:31)
[INFO] [talledLocalContainer] at com.atlassian.jira.component.ComponentAccessor.getComponent(ComponentAccessor.java:176)
[INFO] [talledLocalContainer] at com.sample.restplugin.jira.rest.SampleJiraRestResource.setIssueTypeScheme(SampleJiraRestResource.java:242)
[INFO] [talledLocalContainer] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] [talledLocalContainer] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO] [talledLocalContainer] ... 1 filtered
[INFO

 

Please let me know if there's a alternative way of changing the issue type scheme using a rest plugin module

 

Thanks!

Pasan

 

1 answer

0 votes
Moga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 18, 2018

Hi Pasan,

This looks like a developer question, so it would be better to post it at https://community.developer.atlassian.com, that's where our developer community hangs out :)

Best Regards, 
Mogavenasan

Pasan Uluwatta
Contributor
February 21, 2020

Hey @Moga 

Reply after 1 year + :) , was bit out from the Atlassian community and back again now.

Thanks for letting me know.

Suggest an answer

Log in or Sign up to answer