Ejemplo n.º 1
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());
 }
Ejemplo n.º 2
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)));
    }
  }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 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());
    }
  }