コード例 #1
0
 private String getCanonicalName(FileNode node) {
   String path = node.getPath();
   String result;
   if (isNullOrBlank(path)) {
     result = node.getName();
   } else {
     result = path + node.getName();
   }
   return result;
 }
コード例 #2
0
  /** @param node */
  public void makePublic(final FileNode node, boolean isPublic) {
    String url = node.getRepository() + "/permissions";
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.POST, url);
    builder.setHeader("Content-type", "application/x-www-form-urlencoded");
    StringBuilder args = new StringBuilder();
    args.append("isPublic=");
    args.append(URL.encodeQueryString(Boolean.toString(isPublic)));
    args.append("&filename=");
    args.append(URL.encodeQueryString(getCanonicalName(node)));
    try {
      Request request =
          builder.sendRequest(
              args.toString(),
              new RequestCallback() {
                public void onError(Request request, Throwable exception) {
                  // displayError("Couldn't retrieve JSON "+exception.getMessage());
                }

                public void onResponseReceived(Request request, Response response) {
                  GWT.log("Got reply");
                  if (200 == response.getStatusCode()) {
                    GWT.log("Reply is" + response.getText());
                    GWT.log("Headers is " + response.getHeadersAsString());
                    GWT.log("Status Text " + response.getStatusText());
                    fetchFiles(repositoryUri, node.getPath());
                  } else {
                    Window.alert(
                        "Update failure: " + response.getStatusText() + " " + response.getText());
                  }
                }
              });
    } catch (RequestException e) {
      Window.alert("Update exception: " + e.toString());
    }
  }
コード例 #3
0
  /** @param value */
  public void selectFolder(FileNode value) {
    if (!value.getMime().equals("application/vnd.com.n3phele.Repository+json")) {
      String path =
          value.getPath() == null
              ? value.getName() + "/"
              : (value.getPath() + value.getName() + "/");
      if (path.startsWith("/")) GWT.log("FileNode " + value + " produces query with leading /");
      fetchFiles(value.getRepository(), path);

      History.newItem(historyMapper.getToken(new RepoContentPlace(value.getRepository(), path)));
    } else {
      fetchFiles(value.getRepository(), null);
      History.newItem(historyMapper.getToken(new RepoContentPlace(value.getRepository(), null)));
    }
  }
コード例 #4
0
  /**
   * @param node
   * @param fileDetailsPanel
   */
  public void getOrigin(final FileNode node, final FileDetailsPanel fileDetailsPanel) {

    String url =
        node.getRepository() + "/origin" + "?name=" + URL.encodeQueryString(node.getName());
    if (!isNullOrBlank(node.getPath())) {
      url += "&path=" + URL.encodeQueryString(node.getPath());
    }

    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, url);
    try {
      Request request =
          builder.sendRequest(
              null,
              new RequestCallback() {
                public void onError(Request request, Throwable exception) {
                  // displayError("Couldn't retrieve JSON "+exception.getMessage());
                }

                public void onResponseReceived(Request request, Response response) {
                  GWT.log(response.getStatusCode() + " " + response.getText());
                  if (200 == response.getStatusCode()) {
                    Origin origin = Origin.asOrigin(response.getText());
                    provideOrigin(node, origin, fileDetailsPanel);
                  } else {
                    Window.alert(
                        "Origin fetch failure: "
                            + response.getStatusText()
                            + " "
                            + response.getText());
                  }
                }
              });
    } catch (RequestException e) {
      Window.alert("Origin fetch exception: " + e.toString());
    }
  }
コード例 #5
0
 /** @param folder */
 public void addPlaceholder(FileNode folder) {
   if (placeholderMap == null) this.placeholderMap = new HashMap<String, Map<String, FileNode>>();
   String folderPath = folder.getPath();
   if (!this.placeholderMap.containsKey(folderPath)) {
     this.placeholderMap.put(folderPath, new HashMap<String, FileNode>());
   }
   this.placeholderMap.get(folderPath).put(folder.getName(), folder);
   GWT.log("get " + folder.getRepository() + " " + folderPath);
   fetchFiles(folder.getRepository(), isNullOrBlank(folder.getPath()) ? null : folder.getPath());
 }