<commit_before>source bash-toolbox/init.sh

include app.server.version.AppServerVersion

include base.comparator.BaseComparator
include base.vars.BaseVars

include command.validator.CommandValidator

include database.Database

include file.name.util.FileNameUtil
include file.util.FileUtil
include file.writer.FileWriter

include help.message.HelpMessage

include logger.Logger

include props.writer.util.PropsWriterUtil

include string.validator.StringValidator

@description downloads_nightly_tomcat_bundle_on_indicated_branch
get(){
	cd ${buildDir}

	${_log} info "downloading_nightly_bundle..."

	ant snapshot-bundle

	${_log} info "completed."

	${_log} info "renaming_tomcat_directory..."

	local bundleAppServerDir=${bundleDir}/${APP_SERVER}-${appServerVersion}

	FileUtil deleteIfExists ${bundleAppServerDir}

	mv ${bundleDir}/${APP_SERVER} ${bundleAppServerDir}

	${_log} info "completed."

	if [[ -e ${nightlyDir} ]]; then
		${_log} info "cleaning_out_nightly_directory..."

		rm -rf ${nightlyDir}/*
	else
		${_log} info "constructing_nightly_directory..."

		mkdir -p ${nightlyDir}
	fi

	${_log} info "completed."

	${_log} info "copying_from_bundle_directory_to_nightly_directory..."

	local filePaths=(
		data
		deploy
		license
		logs
		osgi
		${APP_SERVER}-${appServerVersion}
		tools
		work
		.githash
		.liferay-home
		portal-ext.properties
	)

	for _filePath in ${filePaths[@]}; do
		local filePath=${bundleDir}/${_filePath}

		if [[ -e ${filePath} || -d ${filePath} ]]; then
			cp -rf ${filePath} -d ${nightlyDir}
		fi
	done

	${_log} info "completed."

	${_log} info "updating_portal_properties"

	local propsFile=${nightlyDir}/portal-ext.properties

	${replace} ${propsFile} ${baseDatabase} ${nightlyDatabase}

	local _nightlyDir=$(FileNameUtil getPath 1 ${nightlyDir})

	PropsWriterUtil setProps ${propsFile} liferay.home ${_nightlyDir}

	${_log} info "completed."

	Database rebuild ${nightlyDatabase} utf8
}

@description starts_up_nightly_bundle
run(){
	${_log} info "starting_up_${APP_SERVER}_nightly_bundle"
	${nightlyDir}/${APP_SERVER}-${appServerVersion}/bin/catalina.sh run
}

main(){
	local APP_SERVER=tomcat
	local branch=$(BaseVars getBranch $@)

	local appServerVersion=$(
		AppServerVersion getAppServerVersion ${APP_SERVER} ${branch}
	)

	local baseDatabase=lportal${branch//[-.]/}
	local baseDir=$(pwd)

	local buildDir=$(BaseVars getBuildDir ${branch})
	local bundleDir=$(BaseVars getBundleDir ${branch})

	local nightlyDatabase=${baseDatabase}nightly
	local nightlyDir=${HOME}/Desktop/nightly/${branch}/bundles

	local _log="Logger log"
	local replace="FileWriter replace"

	if [[ $(StringValidator isNull ${1}) ]]; then
		HelpMessage printHelpMessage
	else
		until [[ $(StringValidator isNull ${1}) ]]; do<commit_msg>Update URL for private branches<commit_after>source bash-toolbox/init.sh

include app.server.version.AppServerVersion

include base.comparator.BaseComparator
include base.vars.BaseVars

include command.validator.CommandValidator

include database.Database

include file.name.util.FileNameUtil
include file.util.FileUtil
include file.writer.FileWriter

include help.message.HelpMessage

include logger.Logger

include props.writer.PropsWriter
include props.writer.util.PropsWriterUtil

include string.validator.StringValidator

@description downloads_nightly_tomcat_bundle_on_indicated_branch
get(){
	cd ${buildDir}

	${_log} info "downloading_nightly_bundle..."

	if [[ $(BaseVars isPrivate ${branch}) ]]; then
		local url=https://files.liferay.com/private/ee/portal/

		PropsWriter setBuildProps ${branch} snapshot.bundle.base.url ${url}
	fi

	ant snapshot-bundle

	${_log} info "completed."

	${_log} info "renaming_tomcat_directory..."

	local bundleAppServerDir=${bundleDir}/${APP_SERVER}-${appServerVersion}

	FileUtil deleteIfExists ${bundleAppServerDir}

	mv ${bundleDir}/${APP_SERVER} ${bundleAppServerDir}

	${_log} info "completed."

	if [[ -e ${nightlyDir} ]]; then
		${_log} info "cleaning_out_nightly_directory..."

		rm -rf ${nightlyDir}/*
	else
		${_log} info "constructing_nightly_directory..."

		mkdir -p ${nightlyDir}
	fi

	${_log} info "completed."

	${_log} info "copying_from_bundle_directory_to_nightly_directory..."

	local filePaths=(
		data
		deploy
		license
		logs
		osgi
		${APP_SERVER}-${appServerVersion}
		tools
		work
		.githash
		.liferay-home
		portal-ext.properties
	)

	for _filePath in ${filePaths[@]}; do
		local filePath=${bundleDir}/${_filePath}

		if [[ -e ${filePath} || -d ${filePath} ]]; then
			cp -rf ${filePath} -d ${nightlyDir}
		fi
	done

	${_log} info "completed."

	${_log} info "updating_portal_properties"

	local propsFile=${nightlyDir}/portal-ext.properties

	${replace} ${propsFile} ${baseDatabase} ${nightlyDatabase}

	local _nightlyDir=$(FileNameUtil getPath 1 ${nightlyDir})

	PropsWriterUtil setProps ${propsFile} liferay.home ${_nightlyDir}

	${_log} info "completed."

	Database rebuild ${nightlyDatabase} utf8

	mv ${nightlyDir}/${APP_SERVER}-${appServerVersion} ${nightlyDir}/${APP_SERVER}
}

@description starts_up_nightly_bundle
run(){
	${_log} info "starting_up_${APP_SERVER}_nightly_bundle"
	${nightlyDir}/${APP_SERVER}/bin/catalina.sh run
}

main(){
	local APP_SERVER=tomcat
	local branch=$(BaseVars getBranch $@)

	local appServerVersion=$(
		AppServerVersion getAppServerVersion ${APP_SERVER} ${branch}
	)

	local baseDatabase=lportal${branch//[-.]/}
	local baseDir=$(pwd)

	local buildDir=$(BaseVars getBuildDir ${branch})
	local bundleDir=$(BaseVars getBundleDir ${branch})

	local nightlyDatabase=${baseDatabase}nightly
	local nightlyDir=${HOME}/Desktop/nightly/${branch}/bundles

	local _log="Logger log"
	local replace="FileWriter replace"

	if [[ $(StringValidator isNull ${1}) ]]; then
		HelpMessage printHelpMessage
	else
		until [[ $(StringValidator isNull ${1}) ]]; do
{'fraction_non_alphanumeric': 0.1343206474944033, 'fraction_numerical': 0.0013776476666092646, 'mean_word_length': 5.511210762331839, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1003590', 'n_tokens_mistral': 1998, 'n_tokens_neox': 1886, 'n_words': 409}