Example #1
0
  @Override
  public void chatLinkClicked(URI url) {
    String action = url.getPath();
    if (action.equals("/SHOWPREVIEW")) {
      enableReplacement.setSelected(cfg.getBoolean(ReplacementProperty.REPLACEMENT_ENABLE, true));
      enableReplacementProposal.setSelected(
          cfg.getBoolean(ReplacementProperty.REPLACEMENT_PROPOSAL, true));

      currentMessageID = url.getQuery();
      currentLinkPosition = url.getFragment();

      this.setVisible(true);
      this.setLocationRelativeTo(chatPanel);
    }
  }
 private boolean identifyNewCommitResource(
     HttpServletRequest request, HttpServletResponse response, Repository db, String newCommit)
     throws ServletException {
   try {
     URI u = getURI(request);
     IPath p = new Path(u.getPath());
     IPath np = new Path("/"); // $NON-NLS-1$
     for (int i = 0; i < p.segmentCount(); i++) {
       String s = p.segment(i);
       if (i == 2) {
         s += ".." + newCommit; // $NON-NLS-1$
       }
       np = np.append(s);
     }
     if (p.hasTrailingSeparator()) np = np.addTrailingSeparator();
     URI nu =
         new URI(
             u.getScheme(),
             u.getUserInfo(),
             u.getHost(),
             u.getPort(),
             np.toString(),
             u.getQuery(),
             u.getFragment());
     JSONObject result = new JSONObject();
     result.put(ProtocolConstants.KEY_LOCATION, nu);
     OrionServlet.writeJSONResponse(
         request, response, result, JsonURIUnqualificationStrategy.ALL_NO_GIT);
     response.setHeader(
         ProtocolConstants.HEADER_LOCATION, resovleOrionURI(request, nu).toString());
     return true;
   } catch (Exception e) {
     return statusHandler.handleRequest(
         request,
         response,
         new ServerStatus(
             IStatus.ERROR,
             HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
             "An error occured when identifying a new Commit resource.",
             e));
   }
 }
Example #3
0
  /**
   * Evaluates a URI and adds it to the namespace map as a namespace.
   *
   * @param uri URI
   */
  protected void addNamespaceURI(URI uri) {

    if (uri == null) {
      throw new IllegalArgumentException("URI argument is null.");
    }

    // extract URI without fragment
    String uriString = uri.toString();
    String newURI = null;

    if (uriString != null) {

      // determine what comes last a '#' or '/'
      int hashindex = uriString.lastIndexOf('#');
      int slashindex = uriString.lastIndexOf('/');

      // validate (URI must contain a forward slash)
      if (slashindex == -1) {
        // namespace may have been evaluated already
        return;
      }

      // is there a '/' after the '#'?
      if (slashindex > hashindex) {

        // remove everything after the last '/'
        int index = uriString.lastIndexOf('/');
        newURI = uriString.substring(0, index) + "/";
      } else {

        // '#' comes after last '/' (remove entire fragment)
        newURI = uriString.replaceAll(uri.getFragment(), "");
      }

      // only add namespace if it is new
      if ((newURI != null) && (!namespaces.containsValue(newURI))) {
        // add to namespaces
        namespaces.put("ns" + namespaces.size(), newURI);
      }
    }
  }