Search in sources :

Example 1 with AbstractOrganization

use of io.jenkins.blueocean.rest.factory.organization.AbstractOrganization in project blueocean-plugin by jenkinsci.

the class OrganizationStatePreloader method getStateJson.

@Override
public String getStateJson() {
    BlueOrganization organization = Iterables.getFirst(OrganizationFactory.getInstance().list(), null);
    if (organization != null) {
        // default is root group
        String organizationGroup = "/";
        if (organization instanceof AbstractOrganization) {
            organizationGroup = "/" + ((AbstractOrganization) organization).getGroup().getFullName();
        }
        StringWriter writer = new StringWriter();
        new JSONBuilder(writer).object().key("name").value(organization.getName()).key("displayName").value(organization.getDisplayName()).key("organizationGroup").value(organizationGroup).endObject();
        return writer.toString();
    } else {
        // if will happen only when there is no implementation of BlueOrganization found.
        return "{}";
    }
}
Also used : JSONBuilder(net.sf.json.util.JSONBuilder) StringWriter(java.io.StringWriter) BlueOrganization(io.jenkins.blueocean.rest.model.BlueOrganization) AbstractOrganization(io.jenkins.blueocean.rest.factory.organization.AbstractOrganization)

Aggregations

AbstractOrganization (io.jenkins.blueocean.rest.factory.organization.AbstractOrganization)1 BlueOrganization (io.jenkins.blueocean.rest.model.BlueOrganization)1 StringWriter (java.io.StringWriter)1 JSONBuilder (net.sf.json.util.JSONBuilder)1