当前位置: 首页>>代码示例>>Java>>正文


Java Url类代码示例

本文整理汇总了Java中com.google.gerrit.extensions.restapi.Url的典型用法代码示例。如果您正苦于以下问题:Java Url类的具体用法?Java Url怎么用?Java Url使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Url类属于com.google.gerrit.extensions.restapi包,在下文中一共展示了Url类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: redactQueryString

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
@VisibleForTesting
static String redactQueryString(String uri, String qs) {
  if (Strings.isNullOrEmpty(qs)) {
    return uri;
  }

  StringBuilder b = new StringBuilder(uri);
  boolean first = true;
  for (String kvPair : Splitter.on('&').split(qs)) {
    Iterator<String> i = Splitter.on('=').limit(2).split(kvPair).iterator();
    String key = i.next();
    b.append(first ? '?' : '&').append(key);
    first = false;
    if (i.hasNext()) {
      b.append('=');
      if (REDACT_PARAM.contains(Url.decode(key))) {
        b.append('*');
      } else {
        b.append(i.next());
      }
    }
  }
  return b.toString();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:HttpLog.java

示例2: toString

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
@Override
public String toString() {
  final StringBuilder buffer = new StringBuilder();
  char separator = 0;
  if (url != null) {
    separator = '?';
    buffer.append(url);
  }
  for (Map.Entry<String, String> entry : entrySet()) {
    final String key = entry.getKey();
    final String val = entry.getValue();
    if (separator != 0) {
      buffer.append(separator);
    }
    buffer.append(Url.encode(key));
    buffer.append('=');
    if (val != null) {
      buffer.append(Url.encode(val));
    }
    separator = '&';
  }
  return buffer.toString();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:UrlEncoded.java

示例3: update

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
private static Comment update(Comment e, DraftInput in, Timestamp when) {
  if (in.side != null) {
    e.side = in.side();
  }
  if (in.inReplyTo != null) {
    e.parentUuid = Url.decode(in.inReplyTo);
  }
  e.setLineNbrAndRange(in.line, in.range);
  e.message = in.message.trim();
  e.writtenOn = when;
  if (in.tag != null) {
    // TODO(dborowitz): Can we support changing tags via PUT?
    e.tag = in.tag;
  }
  if (in.unresolved != null) {
    e.unresolved = in.unresolved;
  }
  return e;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:PutDraftComment.java

示例4: updateChange

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
@Override
public boolean updateChange(ChangeContext ctx)
    throws ResourceNotFoundException, OrmException, UnprocessableEntityException {
  PatchSet ps = psUtil.get(ctx.getDb(), ctx.getNotes(), psId);
  if (ps == null) {
    throw new ResourceNotFoundException("patch set not found: " + psId);
  }
  String parentUuid = Url.decode(in.inReplyTo);

  comment =
      commentsUtil.newComment(
          ctx, in.path, ps.getId(), in.side(), in.message.trim(), in.unresolved, parentUuid);
  comment.setLineNbrAndRange(in.line, in.range);
  comment.tag = in.tag;

  setCommentRevId(comment, patchListCache, ctx.getChange(), ps);

  commentsUtil.putComments(
      ctx.getDb(), ctx.getUpdate(psId), Status.DRAFT, Collections.singleton(comment));
  ctx.dontBumpLastUpdatedOn();
  return true;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:CreateDraftComment.java

示例5: fillCommentInfo

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
protected void fillCommentInfo(Comment c, CommentInfo r, AccountLoader loader) {
  if (fillPatchSet) {
    r.patchSet = c.key.patchSetId;
  }
  r.id = Url.encode(c.key.uuid);
  r.path = c.key.filename;
  if (c.side <= 0) {
    r.side = Side.PARENT;
    if (c.side < 0) {
      r.parent = -c.side;
    }
  }
  if (c.lineNbr > 0) {
    r.line = c.lineNbr;
  }
  r.inReplyTo = Url.encode(c.parentUuid);
  r.message = Strings.emptyToNull(c.message);
  r.updated = c.writtenOn;
  r.range = toRange(c.range);
  r.tag = c.tag;
  r.unresolved = c.unresolved;
  if (loader != null) {
    r.author = loader.get(c.author.getId());
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:CommentJson.java

示例6: createRobotCommentFromInput

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
private RobotComment createRobotCommentFromInput(
    ChangeContext ctx, String path, RobotCommentInput robotCommentInput) throws OrmException {
  RobotComment robotComment =
      commentsUtil.newRobotComment(
          ctx,
          path,
          psId,
          robotCommentInput.side(),
          robotCommentInput.message,
          robotCommentInput.robotId,
          robotCommentInput.robotRunId);
  robotComment.parentUuid = Url.decode(robotCommentInput.inReplyTo);
  robotComment.url = robotCommentInput.url;
  robotComment.properties = robotCommentInput.properties;
  robotComment.setLineNbrAndRange(robotCommentInput.line, robotCommentInput.range);
  robotComment.tag = in.tag;
  setCommentRevId(robotComment, patchListCache, ctx.getChange(), ps);
  robotComment.fixSuggestions = createFixSuggestionsFromInput(robotCommentInput.fixSuggestions);
  return robotComment;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:PostReview.java

示例7: toPluginInfo

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
public static PluginInfo toPluginInfo(Plugin p) {
  String id;
  String version;
  String indexUrl;
  String filename;
  Boolean disabled;

  id = Url.encode(p.getName());
  version = p.getVersion();
  disabled = p.isDisabled() ? true : null;
  if (p.getSrcFile() != null) {
    indexUrl = String.format("plugins/%s/", p.getName());
    filename = p.getSrcFile().getFileName().toString();
  } else {
    indexUrl = null;
    filename = null;
  }

  return new PluginInfo(id, version, indexUrl, filename, disabled);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:ListPlugins.java

示例8: run

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
@Override
public void run() throws Exception {
  if (listGroups.getUser() != null && !listGroups.getProjects().isEmpty()) {
    throw die("--user and --project options are not compatible.");
  }

  ColumnFormatter formatter = new ColumnFormatter(stdout, '\t');
  for (GroupInfo info : listGroups.get()) {
    formatter.addColumn(MoreObjects.firstNonNull(info.name, "n/a"));
    if (verboseOutput) {
      @SuppressWarnings("deprecation")
      Optional<InternalGroup> group =
          info.ownerId != null
              ? groupCache.get(new AccountGroup.UUID(Url.decode(info.ownerId)))
              : Optional.empty();

      formatter.addColumn(Url.decode(info.id));
      formatter.addColumn(Strings.nullToEmpty(info.description));
      formatter.addColumn(group.map(InternalGroup::getName).orElse("n/a"));
      formatter.addColumn(group.map(g -> g.getGroupUUID().get()).orElse(""));
      formatter.addColumn(
          Boolean.toString(MoreObjects.firstNonNull(info.options.visibleToAll, Boolean.FALSE)));
    }
    formatter.nextLine();
  }
  formatter.finish();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:28,代码来源:ListGroupsCommand.java

示例9: callback

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
private void callback(final boolean isNew, HttpServletRequest req, HttpServletResponse rsp)
    throws IOException {
  String token = req.getParameter(P_TOKEN);
  if (token == null || token.isEmpty() || token.startsWith("/SignInFailure,")) {
    token = PageLinks.MINE;
  }

  final StringBuilder rdr = new StringBuilder();
  rdr.append(urlProvider.get(req));
  if (isNew && !token.startsWith(PageLinks.REGISTER + "/")) {
    rdr.append('#' + PageLinks.REGISTER);
  }
  rdr.append(Url.decode(token));
  rsp.sendRedirect(rdr.toString());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:16,代码来源:OpenIdServiceImpl.java

示例10: authenticateAndRedirect

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
private void authenticateAndRedirect(
    HttpServletRequest req, HttpServletResponse rsp, OAuthToken token) throws IOException {
  AuthRequest areq = new AuthRequest(ExternalId.Key.parse(user.getExternalId()));
  AuthResult arsp;
  try {
    String claimedIdentifier = user.getClaimedIdentity();
    if (!Strings.isNullOrEmpty(claimedIdentifier)) {
      if (!authenticateWithIdentityClaimedDuringHandshake(areq, rsp, claimedIdentifier)) {
        return;
      }
    } else if (linkMode) {
      if (!authenticateWithLinkedIdentity(areq, rsp)) {
        return;
      }
    }
    areq.setUserName(user.getUserName());
    areq.setEmailAddress(user.getEmailAddress());
    areq.setDisplayName(user.getDisplayName());
    arsp = accountManager.authenticate(areq);

    accountId = arsp.getAccountId();
    tokenCache.put(accountId, token);
  } catch (AccountException e) {
    log.error("Unable to authenticate user \"" + user + "\"", e);
    rsp.sendError(HttpServletResponse.SC_FORBIDDEN);
    return;
  }

  webSession.get().login(arsp, true);
  String suffix = redirectToken.substring(OAuthWebFilter.GERRIT_LOGIN.length() + 1);
  suffix = CharMatcher.anyOf("/").trimLeadingFrom(Url.decode(suffix));
  StringBuilder rdr = new StringBuilder(urlProvider.get(req));
  rdr.append(suffix);
  rsp.sendRedirect(rdr.toString());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:36,代码来源:OAuthSession.java

示例11: getLoginRedirectUrl

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
private static String getLoginRedirectUrl(HttpServletRequest req) {
  String contextPath = req.getContextPath();
  String loginUrl = contextPath + "/login/";
  String token = req.getRequestURI();
  if (!contextPath.isEmpty()) {
    token = token.substring(contextPath.length());
  }

  String queryString = req.getQueryString();
  if (queryString != null && !queryString.isEmpty()) {
    token = token.concat("?" + queryString);
  }
  return (loginUrl + Url.encode(token));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:GitwebServlet.java

示例12: getParameters

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
private static Map<String, String> getParameters(HttpServletRequest req) {
  final Map<String, String> params = new HashMap<>();
  for (String pair : req.getQueryString().split("[&;]")) {
    final int eq = pair.indexOf('=');
    if (0 < eq) {
      String name = pair.substring(0, eq);
      String value = pair.substring(eq + 1);

      name = Url.decode(name);
      value = Url.decode(value);
      params.put(name, value);
    }
  }
  return params;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:16,代码来源:GitwebServlet.java

示例13: format

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
public ProjectInfo format(Project p) {
  ProjectInfo info = new ProjectInfo();
  info.name = p.getName();
  Project.NameKey parentName = p.getParent(allProjects);
  info.parent = parentName != null ? parentName.get() : null;
  info.description = Strings.emptyToNull(p.getDescription());
  info.state = p.getState();
  info.id = Url.encode(info.name);
  List<WebLinkInfo> links = webLinks.getProjectLinks(p.getName());
  info.webLinks = links.isEmpty() ? null : links;
  return info;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:13,代码来源:ProjectJson.java

示例14: parse

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
private DashboardResource parse(ProjectState projectState, CurrentUser user, String id)
    throws ResourceNotFoundException, IOException, ConfigInvalidException,
        PermissionBackendException {
  List<String> p = Lists.newArrayList(Splitter.on(':').limit(2).split(id));
  String ref = Url.encode(p.get(0));
  String path = Url.encode(p.get(1));
  return dashboards.parse(
      new ProjectResource(projectState, user), IdString.fromUrl(ref + ':' + path));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:GetDashboard.java

示例15: newDashboardInfo

import com.google.gerrit.extensions.restapi.Url; //导入依赖的package包/类
public static DashboardInfo newDashboardInfo(String ref, String path) {
  DashboardInfo info = new DashboardInfo();
  info.ref = ref;
  info.path = path;
  info.id = Joiner.on(':').join(Url.encode(ref), Url.encode(path));
  return info;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:DashboardsCollection.java


注:本文中的com.google.gerrit.extensions.restapi.Url类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。