use of io.jenkins.blueocean.rest.model.BlueOrganization in project blueocean-plugin by jenkinsci.
the class UserSearch method search.
@Override
public Pageable<BlueUser> search(Query q) {
List<BlueUser> users = new ArrayList<>();
BlueOrganization organization = getOrganization(q);
if (organization == null) {
organization = OrganizationFactory.getInstance().list().iterator().next();
}
for (hudson.model.User u : hudson.model.User.getAll()) {
users.add(new UserImpl(organization, u));
}
return Pageables.wrap(users);
}
use of io.jenkins.blueocean.rest.model.BlueOrganization in project blueocean-plugin by jenkinsci.
the class UserSearch method getOrganization.
/**
* Obtains the organization from the query. It will return an error if the parameter is absent or the organization
* could not be found.
*
* @param q the query parameter
* @return the organization if found
*/
public BlueOrganization getOrganization(Query q) {
String org = q.param("organization");
if (org == null) {
return null;
}
// This could return null and is ok for the UserImpl which will use Jenkins base.
BlueOrganization organization = OrganizationFactory.getInstance().get(org);
return organization;
}
use of io.jenkins.blueocean.rest.model.BlueOrganization in project blueocean-plugin by jenkinsci.
the class BlueTrendTest method testTrendsIdCollision.
@Test
public void testTrendsIdCollision() throws Exception {
// verify the extension did register correctly
ExtensionList<BlueTrendFactory> extensionList = ExtensionList.lookup(BlueTrendFactory.class);
Assert.assertEquals(2, extensionList.size());
Project project = j.createProject(FreeStyleProject.class, "freestyle1");
BlueOrganization org = new OrganizationImpl("jenkins", j.jenkins);
BluePipeline pipeline = new AbstractPipelineImpl(org, project);
BlueTrendContainer trends = pipeline.getTrends();
BlueTrend trend = trends.get("junit");
Assert.assertEquals("junit", trend.getId());
Assert.assertEquals("JUnit", trend.getDisplayName());
}
use of io.jenkins.blueocean.rest.model.BlueOrganization in project blueocean-plugin by jenkinsci.
the class BlueOceanUrlMapperImpl method getUrl.
@Override
public String getUrl(@Nonnull ModelObject modelObject) {
BlueOrganization organization = getOrganization(modelObject);
if (organization == null) {
// no organization, best we can do is to land user on landing page
return getLandingPagePath();
}
String organizationName = organization.getName();
String baseUrl = getOrgPrefix(organizationName);
if (modelObject instanceof ModifiableTopLevelItemGroup) {
return baseUrl;
} else if (modelObject instanceof Job) {
BluePipeline blueResource = getJobResource(modelObject);
if (blueResource != null) {
return getPipelineUrl(baseUrl, blueResource);
}
} else if (modelObject instanceof Run) {
Run run = (Run) modelObject;
Job job = run.getParent();
BluePipeline blueResource = getJobResource(job);
if (blueResource != null) {
// encoded and re-encode to do the full monty. Nasty :)
return baseUrl + "/" + encodeURIComponent(blueResource.getFullName()) + "/detail/" + encodeURIComponent(decodeURIComponent(job.getName())) + "/" + encodeURIComponent(run.getId());
}
} else if (modelObject instanceof Item) {
Resource bluePipeline = BluePipelineFactory.resolve((Item) modelObject);
if (bluePipeline instanceof BlueMultiBranchPipeline) {
return getPipelineUrl(baseUrl, (BluePipeline) bluePipeline);
}
}
return null;
}
Aggregations