Esempio n. 1
0
 public boolean addFileToRepository(File fileToAdd) {
   Boolean result = false;
   try {
     String finalFilePath =
         fileToAdd
             .getPath()
             .substring(
                 fileToAdd.getPath().indexOf(baseFolder.getPath())
                     + baseFolder.getPath().length()
                     + 1);
     git.add().addFilepattern(finalFilePath).call();
     result = true;
   } catch (NoFilepatternException e) {
     logger.debug("Unable to add file on repository ", e);
   } catch (GitAPIException e) {
     logger.debug("Unable to add file on repository ", e);
   }
   return result;
 }
Esempio n. 2
0
  @Override
  @Port(name = "files", method = "mkdirs")
  public boolean mkdirs(String relativePath) {
    File f1 = new File(baseFolder.getAbsolutePath() + relativePath);

    addFileToRepository(f1);
    commitRepository(
        " folders " + f1.getPath() + " created ", " name ", " email "); // TODO fix name and email

    return !f1.exists() && f1.mkdirs();
  }
Esempio n. 3
0
 public void process(File file, FolderItem item) {
   if (!file.getName().contains(".git") && !file.getName().endsWith("~")) {
     if (file.isFile()) {
       FileItem itemToAdd = new FileItem();
       itemToAdd.setName(file.getName());
       itemToAdd.setParent(item);
       itemToAdd.setPath(getRelativePath(file.getPath()));
       item.add(itemToAdd);
     } else if (file.isDirectory()) {
       FolderItem folder = new FolderItem();
       folder.setName(file.getName());
       folder.setParent(item);
       folder.setPath(getRelativePath(file.getPath() + "/"));
       item.add(folder);
       File[] listOfFiles = file.listFiles();
       if (listOfFiles != null) {
         for (File listOfFile : listOfFiles) process(listOfFile, folder);
       }
     }
   }
 }
Esempio n. 4
0
 public boolean removeFileToRepository(File fileToRemove) {
   Boolean result = false;
   try {
     String finalFilePath =
         fileToRemove
             .getPath()
             .substring(
                 fileToRemove.getPath().indexOf(baseFolder.getPath())
                     + baseFolder.getPath().length()
                     + 1);
     logger.debug(" file f " + fileToRemove.getPath() + " string " + finalFilePath);
     git.rm().addFilepattern(finalFilePath).call();
     commitRepository(
         " File " + finalFilePath + " removed ", " name ", " email "); // TODO fix name and email
     result = true;
   } catch (NoFilepatternException e) {
     logger.debug("Cannot remove file to repository " + e);
   } catch (GitAPIException e) {
     logger.debug("Unable to remove file on repository ", e);
   }
   return result;
 }