Checks in content from a source directory into the current git repository.
@param sourceDirectory The directory to pull content in from.
@param message The commit message to use.
@return The new SHA revision.
@throws Exception
348401
public String checkinNewContent(String sourceDirectory, String message) throws Exception {
    RmCommand remove = git.rm();
    boolean hasFiles = false;
    for(String filename : new File(getBaseDirectory()).list()) {
      if(!filename.equals(".git")) {
        remove.addFilepattern(filename);
        hasFiles = true;
      }
    }
    if(hasFiles) {
      log.info("Removing old content.");
      remove.call();
    }
    log.info("Copying in new content.");
    FileSystemManager.copyAllContent(sourceDirectory, getBaseDirectory(), true);
    log.info("Adding new content.");
    AddCommand add = git.add();
    for(String filename : new File(getBaseDirectory()).list()) {
      if(!filename.equals(".git")) {
        add.addFilepattern(filename);
      }
    }
    add.call();
    log.info("Committing new content.");
    git.commit().setMessage(message).call();
    return getCurrentRevision();
  }
84878
def commit_source_archive(file, message)
      from_directory do
        result_dir = File.join(packages_dir, name)
        FileUtils.mkdir_p(result_dir)

        result_path = File.join(result_dir, File.basename(file))
        FileUtils.cp(file, result_path)
        @git.commit_file(result_path, "Source archive added")

        unarchiver = if file =~ /\.zip$/
                       Tetra::Unzip.new
                     else
                       Tetra::Tar.new
                     end

        Dir.glob(File.join("src", "*")).each { |f| FileUtils.rm_rf(f) }
        unarchiver.decompress(file, "src")
        commit_sources(message, true)
      end
    end
339230
protected static void checkIsFolder(CmsResource resource) throws CmsException {

        if (!isFolder(resource)) {
            throw new CmsIllegalArgumentException(
                Messages.get().container(
                    org.opencms.file.Messages.ERR_REWRITE_LINKS_ROOT_NOT_FOLDER_1,
                    resource.getRootPath()));
        }
    }
891867
protected String readSarlEclipseSetting(String sourceDirectory) {
		if (this.propertiesFileLocation != null) {
			final File file = new File(this.propertiesFileLocation);
			if (file.canRead()) {
				final Properties sarlSettings = new Properties();
				try (FileInputStream stream = new FileInputStream(file)) {
					sarlSettings.load(stream);
					final String sarlOutputDirProp = sarlSettings.getProperty("outlet.DEFAULT_OUTPUT.directory", null); //$NON-NLS-1$
					if (sarlOutputDirProp != null) {
						final File srcDir = new File(sourceDirectory);
						getLog().debug(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_7,
								srcDir.getPath(), srcDir.exists()));
						if (srcDir.exists() && srcDir.getParent() != null) {
							final String path = new File(srcDir.getParent(), sarlOutputDirProp).getPath();
							getLog().debug(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_8, sarlOutputDirProp));
							return path;
						}
					}
				} catch (FileNotFoundException e) {
					getLog().warn(e);
				} catch (IOException e) {
					getLog().warn(e);
				}
			} else {
				getLog().debug(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_9, this.propertiesFileLocation));
			}
		}
		return null;
	}
679105
public static Entry<Void> ofDirectory(Revision revision, String path) {
        return new Entry<>(revision, path, EntryType.DIRECTORY, null);
    }
1153245
protected void checkNotSubPath(String source, String target) {

        source = CmsStringUtil.joinPaths("/", source, "/");
        target = CmsStringUtil.joinPaths("/", target, "/");
        if (target.startsWith(source)) {
            throw new CmsIllegalArgumentException(
                org.opencms.file.Messages.get().container(
                    org.opencms.file.Messages.ERR_REWRITE_LINKS_ROOTS_DEPENDENT_2,
                    source,
                    target));
        }
    }
710167
public void cd(String target) throws Exception {

        String folder = CmsResource.getFolderPath(m_cms.getRequestContext().getUri());
        if (!target.endsWith("/")) {
            target += "/";
        }
        String resolvedTarget = CmsLinkManager.getAbsoluteUri(target, folder);
        CmsResource res = m_cms.readResource(resolvedTarget);
        if (!res.isFolder()) {
            throw new CmsIllegalArgumentException(
                Messages.get().container(Messages.ERR_NOT_A_FOLDER_1, resolvedTarget));
        }
        m_cms.getRequestContext().setUri(resolvedTarget);
        m_shell.getOut().println(
            '\n' + getMessages().key(Messages.GUI_SHELL_CURRENT_FOLDER_1, new Object[] {resolvedTarget}));
        m_shell.getOut().println();
    }
37169
@Post("/projects/{projectName}/repos/{repoName}/contents")
    @RequiresWritePermission
    public CompletableFuture<PushResultDto> push(
            @Param("revision") @Default("-1") String revision,
            Repository repository,
            Author author,
            CommitMessageDto commitMessage,
            @RequestConverter(ChangesRequestConverter.class) Iterable<Change<?>> changes) {

        final long commitTimeMillis = System.currentTimeMillis();
        return push(commitTimeMillis, author, repository, new Revision(revision), commitMessage, changes)
                .toCompletableFuture()
                .thenApply(rrev -> convert(rrev, commitTimeMillis));
    }
617492
public void createSharedFolder() throws Exception {

        String originalSiteRoot = m_cms.getRequestContext().getSiteRoot();
        CmsProject originalProject = m_cms.getRequestContext().getCurrentProject();
        try {
            m_cms.getRequestContext().setSiteRoot("");
            m_cms.getRequestContext().setCurrentProject(m_cms.createTempfileProject());
            if (!m_cms.existsResource("/shared")) {
                m_cms.createResource("/shared", OpenCms.getResourceManager().getResourceType("folder"));
            }

            try {
                m_cms.lockResourceTemporary("/shared");
            } catch (CmsException e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
            try {
                m_cms.chacc("/shared", "group", "Users", "+v+w+r+i");
            } catch (CmsException e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
            CmsResource shared = m_cms.readResource("/shared");
            try {
                OpenCms.getPublishManager().publishProject(
                    m_cms,
                    new CmsHtmlReport(m_cms.getRequestContext().getLocale(), m_cms.getRequestContext().getSiteRoot()),
                    shared,
                    false);
                OpenCms.getPublishManager().waitWhileRunning();
            } catch (CmsException e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
        } finally {
            m_cms.getRequestContext().setSiteRoot(originalSiteRoot);
            m_cms.getRequestContext().setCurrentProject(originalProject);
        }

    }
1345788
public function setRepositoryPath($repository_path, $createNew = false, $_init = true)
    {
        if (is_string($repository_path)) {
            if ($new_path = realpath($repository_path)) {
                $repository_path = $new_path;
                if (is_dir($repository_path)) {
                    if (file_exists($repository_path."/.git") && is_dir($repository_path."/.git")) {
                        $this->repository_path = $repository_path;
                    } else {
                        if ($createNew) {
                            $this->repository_path = $repository_path;
                            if ($_init) {
                                $this->run('init');
                            }
                        } else {
                            throw new \Exception(
                                sprintf('"%s" is not a git repository!', $repository_path)
                            );
                        }
                    }
                } else {
                    throw new \Exception(
                        sprintf('"%s" is not a directory', $repository_path)
                    );
                }
            } else {
                if ($createNew) {
                    if ($parent = realpath(dirname($repository_path))) {
                        mkdir($repository_path);
                        $this->repository_path = $repository_path;
                        if ($_init) {
                            $this->run('init');
                        }
                    } else {
                        throw new \Exception('Cannot create repository in non-existent directory');
                    }
                } else {
                    throw new \Exception(
                        sprintf('"%s" does not exist', $repository_path)
                    );
                }
            }
        }
    }
252046
public static void CopyDir(String sourcedir, String destdir) throws Exception {
		File dest = new File(destdir);
		File source = new File(sourcedir);

		String[] files = source.list();
		try {
			makehome(destdir);
		} catch (Exception ex) {
			throw new Exception("CopyDir:" + ex.getMessage());
		}

		for (int i = 0; i < files.length; i++) {
			String sourcefile = source + File.separator + files[i];
			String destfile = dest + File.separator + files[i];
			File temp = new File(sourcefile);
			if (temp.isFile()) {
				try {
					copy(sourcefile, destfile);
				} catch (Exception ex) {
					throw new Exception("CopyDir:" + ex.getMessage());
				}
			}
		}
	}
1103247
protected final SourceFolder getOrCreateSourceFolder(String name) {
		SourceFolder sourceFolder = this.sourceFolders.get(name);
		if (sourceFolder == null) {
			sourceFolder = new SourceFolder(name);
			this.sourceFolders.put(name, sourceFolder);
		}
		return sourceFolder;
	}
1068417
@Override
  public final File getIncludeDirectory(final File baseDir, final String artifactId, final String version) {
    return new File(baseDir, this.fileLayout.getIncludeDirectory());
  }
184549
protected boolean uploadDirectory(final String ftpServer, final String username, final String password,
                                      final String sourceDirectoryPath, final String targetDirectoryPath) {
        log.debug("FTP username: " + username);
        try {
            final FTPClient ftpClient = getFTPClient(ftpServer, username, password);

            log.info(String.format(UPLOAD_DIR_START, sourceDirectoryPath, targetDirectoryPath));
            uploadDirectory(ftpClient, sourceDirectoryPath, targetDirectoryPath, "");
            log.info(String.format(UPLOAD_DIR_FINISH, sourceDirectoryPath, targetDirectoryPath));

            ftpClient.disconnect();
            return true;
        } catch (Exception e) {
            log.debug(e);
            log.error(String.format(UPLOAD_DIR_FAILURE, sourceDirectoryPath, targetDirectoryPath));
        }

        return false;
    }
374852
public static void initEndpointDirectory(MuleContext muleContext, String endpointName) throws Exception {

		logger.info("Init directory for endpoint: {}", endpointName);
		
		FTPClient ftpClient = null;

		try {
			ftpClient = getFtpClient(muleContext, endpointName);
	
			EndpointURI endpointURI = getImmutableEndpoint(muleContext, endpointName).getEndpointURI();
			String path = endpointURI.getPath();
	
			try {
				if (path.startsWith("/~/")) {
					path = path.substring(3); // Strip off the leading "/~/" to apply the command to the home-folder
				
				} else if (path.startsWith("/")) {
					path = path.substring(1); // Strip off the leading "/" to apply the command to the home-folder
				}
				recursiveDeleteDirectory(ftpClient, path);
				recursiveCreateDirectory(ftpClient, path);
			} catch (IOException e) {
				if (logger.isErrorEnabled()) logger.error("Failed to recursivly delete endpoint " + endpointName, e);
			}
			
		} finally {
			if (ftpClient != null) {
				ftpClient.disconnect();
			}
		}
	}
607376
protected UserMessage createTellMessage (BodyObject source, String message)
    {
        return UserMessage.create(source.getVisibleName(), message);
    }
20528
public boolean commitInsert(MessageItem msg) throws SIResourceException
  {   
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "commitInsert", msg); 
    boolean updated = updateSourceStream(msg, false);
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "commitInsert", new Boolean(updated));
    return updated;
  }