Search in sources :

Example 1 with UrlEncoded

use of com.google.gerrit.server.UrlEncoded in project gerrit by GerritCodeReview.

the class DashboardsCollection method parse.

static DashboardInfo parse(Project definingProject, String refName, String path, Config config, String project, boolean setDefault) {
    DashboardInfo info = new DashboardInfo(refName, path);
    info.project = project;
    info.definingProject = definingProject.getName();
    String query = config.getString("dashboard", null, "title");
    info.title = replace(project, query == null ? info.path : query);
    info.description = replace(project, config.getString("dashboard", null, "description"));
    info.foreach = config.getString("dashboard", null, "foreach");
    if (setDefault) {
        String id = refName + ":" + path;
        info.isDefault = id.equals(defaultOf(definingProject)) ? true : null;
    }
    UrlEncoded u = new UrlEncoded("/dashboard/");
    u.put("title", MoreObjects.firstNonNull(info.title, info.path));
    if (info.foreach != null) {
        u.put("foreach", replace(project, info.foreach));
    }
    for (String name : config.getSubsections("section")) {
        Section s = new Section();
        s.name = name;
        s.query = config.getString("section", name, "query");
        u.put(s.name, replace(project, s.query));
        info.sections.add(s);
    }
    info.url = u.toString().replace("%3A", ":");
    return info;
}
Also used : UrlEncoded(com.google.gerrit.server.UrlEncoded) IdString(com.google.gerrit.extensions.restapi.IdString)

Example 2 with UrlEncoded

use of com.google.gerrit.server.UrlEncoded in project gerrit by GerritCodeReview.

the class OpenIdServiceImpl method init.

private State init(HttpServletRequest req, final String openidIdentifier, final SignInMode mode, final boolean remember, final String returnToken) {
    final List<?> list;
    try {
        list = manager.discover(openidIdentifier);
    } catch (DiscoveryException e) {
        log.error("Cannot discover OpenID " + openidIdentifier, e);
        return null;
    }
    if (list == null || list.isEmpty()) {
        return null;
    }
    final String contextUrl = urlProvider.get(req);
    final DiscoveryInformation discovered = manager.associate(list);
    final UrlEncoded retTo = new UrlEncoded(contextUrl + RETURN_URL);
    retTo.put(P_MODE, mode.name());
    if (returnToken != null && returnToken.length() > 0) {
        retTo.put(P_TOKEN, returnToken);
    }
    if (remember) {
        retTo.put(P_REMEMBER, "1");
    }
    if (discovered.hasClaimedIdentifier()) {
        retTo.put(P_CLAIMED, discovered.getClaimedIdentifier().getIdentifier());
    }
    return new State(discovered, retTo, contextUrl);
}
Also used : DiscoveryInformation(org.openid4java.discovery.DiscoveryInformation) UrlEncoded(com.google.gerrit.server.UrlEncoded) DiscoveryException(org.openid4java.discovery.DiscoveryException)

Aggregations

UrlEncoded (com.google.gerrit.server.UrlEncoded)2 IdString (com.google.gerrit.extensions.restapi.IdString)1 DiscoveryException (org.openid4java.discovery.DiscoveryException)1 DiscoveryInformation (org.openid4java.discovery.DiscoveryInformation)1