Problem with Eclipse connector

There is no compliant JSON parser for multicascadeselect, its a problem for other plugin using it like Eclipse Connector. Can you implement JSON like cascadingselect to use the official parser ?

org.codehaus.jettison.json.JSONException: Cannot find parser for field witch schema: FieldSchema{type=array, items=string, system=null, custom=com.sourcesense.jira.plugin.cascadingselect:multi-level-cascading-select, customId=10600}

3 answers

org.codehaus.jettison.json.JSONException: Cannot find parser for field witch schema: FieldSchema{type=array, items=string, system=null, custom=com.sourcesense.jira.plugin.cascadingselect:multi-level-cascading-select, customId=10600}

Problem solved with an extended type :

/**
 * 
 */
package com.sourcesense.jira.plugin.customfield.type;

import java.util.List;

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.customfields.manager.GenericConfigManager;
import com.atlassian.jira.issue.customfields.manager.OptionsManager;
import com.atlassian.jira.issue.customfields.option.Option;
import com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem;
import com.atlassian.jira.issue.fields.rest.FieldJsonRepresentation;
import com.atlassian.jira.issue.fields.rest.json.JsonData;
import com.atlassian.jira.issue.fields.rest.json.JsonType;
import com.atlassian.jira.issue.fields.rest.json.JsonTypeBuilder;
import com.atlassian.jira.issue.fields.rest.json.beans.CustomFieldOptionJsonBean;
import com.atlassian.jira.issue.fields.rest.json.beans.JiraBaseUrls;
import com.sourcesense.jira.plugin.util.LicenseUtils;
import com.sourcesense.jira.plugin.customfield.util.MultiLevelCascadingSelectOptionUtils;

public class MultiLevelCascadingSelectCFTypeExtend extends MultiLevelCascadingSelectCFType {

    private final JiraBaseUrls jiraBaseUrls;

    public MultiLevelCascadingSelectCFTypeExtend(OptionsManager optionsManager, CustomFieldValuePersister customFieldValuePersister, GenericConfigManager genericConfigManager, JiraBaseUrls jiraBaseUrls, MultiLevelCascadingSelectOptionUtils optionUtils,
        LicenseUtils licenseUtils) {
        super(optionsManager, customFieldValuePersister, genericConfigManager, jiraBaseUrls, optionUtils, licenseUtils);
        this.jiraBaseUrls = jiraBaseUrls;
    }

    @Override
    public JsonType getJsonSchema(CustomField customField) {
        return JsonTypeBuilder.customArray(JsonType.STRING_TYPE, "com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect", customField.getIdAsLong());
    }

    @Override
    public FieldJsonRepresentation getJsonFromIssue(CustomField customField, Issue issue, boolean renderedVersionRequested, FieldLayoutItem fieldLayoutItem) {
        List<Option> options = getValueFromIssue(customField, issue);
        if ((options == null) || (options.size() == 0)) {
            return new FieldJsonRepresentation(new JsonData(null));
        }
        CustomFieldOptionJsonBean child = null;
        CustomFieldOptionJsonBean fullBean = null;
        if (options.size() >= 2) {
            for (int i = options.size(); i > 0; i--) {
                Option option = options.get(i - 1);
                CustomFieldOptionJsonBean current = CustomFieldOptionJsonBean.shortBean(option, this.jiraBaseUrls);
                if (child != null) {
                    current.setChild(child);
                }
                if (i == 1) {
                    fullBean = current;
                } else {
                    child = current;
                }
            }
        } else if (options.size() == 1) {
            Option option = options.get(0);
            fullBean = CustomFieldOptionJsonBean.shortBean(option, this.jiraBaseUrls);
        }
        JsonData jsonData = new JsonData(fullBean);
        return new FieldJsonRepresentation(jsonData);
    }

}

With this solution, JSON file is hierarchical and we force eclipse connector to use CascadingSelect Jira parser for JSON.

JSON format with MultiLevelCascadingSelectCFType :

customfield_10600": [

    {
        "self": "https://XXX/jira/rest/api/2/customFieldOption/114400",
        "value": "[IT2] BDD / Databases",
        "id": "114400",
        "children": [ … ]
    },
    {
        "self": "https://XXX/jira/rest/api/2/customFieldOption/114413",
        "value": "ORACLE",
        "id": "114413",
        "children": [ … ]
    },
    {
        "self": "https://XXX/jira/rest/api/2/customFieldOption/115209",
        "value": "DATABASE : DUMP / LOAD FROM DISK",
        "id": "115209"
    }

]

JSON format with MultiLevelCascadingSelectCFTypeExtend :

"customfield_10600": {

    "self": "https://XXX/jira/rest/api/2/customFieldOption/114400",
    "value": "[IT2] BDD / Databases",
    "id": "114400",
    "child": {
        "self": "https://XXX/jira/rest/api/2/customFieldOption/114413",
        "value": "ORACLE",
        "id": "114413",
        "child": {
            "self": "https://XXX/jira/rest/api/2/customFieldOption/115208",
            "value": "PERFORMANCE ISSUE",
            "id": "115208"
        },
        "children": [ … ]
    },
    "children": [ … ]

}

Today we are using version 2.5 of this plugin and we wish to migrate to the new version 3.0.1 and to JIRA 6.1

Can you integrate a similar correction to your new version ?

Thanks

org.codehaus.jettison.json.JSONException: Cannot find parser for field witch schema: FieldSchema{type=array, items=string, system=null, custom=com.sourcesense.jira.plugin.cascadingselect:multi-level-cascading-select, customId=10600}

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,155 views 0 8
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