mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-29 15:21:53 +00:00
Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@125605 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,39 +1,39 @@
|
||||
package org.alfresco.repo.domain.schema.script;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
|
||||
/**
|
||||
* Executes a set of zero or more SQL scripts.
|
||||
*
|
||||
* @author Matt Ward
|
||||
*/
|
||||
public interface ScriptBundleExecutor
|
||||
{
|
||||
/**
|
||||
* Runs a bundle of scripts. If any script within the bundle fails, then the rest of the files are not run.
|
||||
*
|
||||
* @param logOnly <tt>true</tt> to catch and log any exceptions or <tt>false</tt> to rethrow
|
||||
* @param dir Directory where the script bundle may be found.
|
||||
* @param scripts Names of the SQL scripts to run, relative to the specified directory.
|
||||
* @throws AlfrescoRuntimeException if a script fails and the <tt>logOnly</tt> flag is <tt>false</tt>
|
||||
*/
|
||||
void exec(boolean logOnly, String dir, String... scripts);
|
||||
|
||||
/**
|
||||
* Runs a bundle of scripts. If any script within the bundle fails, then the rest of the files are not run.
|
||||
*
|
||||
* @param dir Directory where the script bundle may be found.
|
||||
* @param scripts Names of the SQL scripts to run, relative to the specified directory.
|
||||
*/
|
||||
void exec(String dir, String... scripts);
|
||||
|
||||
/**
|
||||
* Runs a bundle of scripts. If any script within the bundle fails, then the rest of the files
|
||||
* are not run, with the exception of postScript - which is always run (a clean-up script for example).
|
||||
*
|
||||
* @param dir Directory where the script bundle may be found.
|
||||
* @param postScript A script that is always run after the other scripts.
|
||||
* @param scripts Names of the SQL scripts to run, relative to the specified directory.
|
||||
*/
|
||||
void execWithPostScript(String dir, String postScript, String... scripts);
|
||||
}
|
||||
package org.alfresco.repo.domain.schema.script;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
|
||||
/**
|
||||
* Executes a set of zero or more SQL scripts.
|
||||
*
|
||||
* @author Matt Ward
|
||||
*/
|
||||
public interface ScriptBundleExecutor
|
||||
{
|
||||
/**
|
||||
* Runs a bundle of scripts. If any script within the bundle fails, then the rest of the files are not run.
|
||||
*
|
||||
* @param logOnly <tt>true</tt> to catch and log any exceptions or <tt>false</tt> to rethrow
|
||||
* @param dir Directory where the script bundle may be found.
|
||||
* @param scripts Names of the SQL scripts to run, relative to the specified directory.
|
||||
* @throws AlfrescoRuntimeException if a script fails and the <tt>logOnly</tt> flag is <tt>false</tt>
|
||||
*/
|
||||
void exec(boolean logOnly, String dir, String... scripts);
|
||||
|
||||
/**
|
||||
* Runs a bundle of scripts. If any script within the bundle fails, then the rest of the files are not run.
|
||||
*
|
||||
* @param dir Directory where the script bundle may be found.
|
||||
* @param scripts Names of the SQL scripts to run, relative to the specified directory.
|
||||
*/
|
||||
void exec(String dir, String... scripts);
|
||||
|
||||
/**
|
||||
* Runs a bundle of scripts. If any script within the bundle fails, then the rest of the files
|
||||
* are not run, with the exception of postScript - which is always run (a clean-up script for example).
|
||||
*
|
||||
* @param dir Directory where the script bundle may be found.
|
||||
* @param postScript A script that is always run after the other scripts.
|
||||
* @param scripts Names of the SQL scripts to run, relative to the specified directory.
|
||||
*/
|
||||
void execWithPostScript(String dir, String postScript, String... scripts);
|
||||
}
|
||||
|
||||
@@ -1,73 +1,73 @@
|
||||
package org.alfresco.repo.domain.schema.script;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* {@link ScriptBundleExecutor} implementation. Uses the supplied {@link ScriptExecutor}
|
||||
* to invoke multiple SQL scripts in a particular directory.
|
||||
*
|
||||
* @author Matt Ward
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
public class ScriptBundleExecutorImpl implements ScriptBundleExecutor
|
||||
{
|
||||
private ScriptExecutor scriptExecutor;
|
||||
protected Log log = LogFactory.getLog(ScriptBundleExecutorImpl.class);
|
||||
|
||||
public ScriptBundleExecutorImpl(ScriptExecutor scriptExecutor)
|
||||
{
|
||||
this.scriptExecutor = scriptExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exec(boolean logOnly, String dir, String... scripts)
|
||||
{
|
||||
for (String name : scripts)
|
||||
{
|
||||
File file = new File(dir, name);
|
||||
try
|
||||
{
|
||||
scriptExecutor.executeScriptUrl(file.getPath());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
String msg = "Unable to run SQL script: dir=" + dir + ", name=" + name;
|
||||
if (logOnly)
|
||||
{
|
||||
log.error(msg, e);
|
||||
// Do not run any more scripts.
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Client opted to rethrow
|
||||
throw new AlfrescoRuntimeException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exec(String dir, String... scripts)
|
||||
{
|
||||
this.exec(true, dir, scripts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execWithPostScript(String dir, String postScript, String... scripts)
|
||||
{
|
||||
try
|
||||
{
|
||||
exec(true, dir, scripts);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Always run the post-script.
|
||||
exec(true, dir, postScript);
|
||||
}
|
||||
}
|
||||
}
|
||||
package org.alfresco.repo.domain.schema.script;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* {@link ScriptBundleExecutor} implementation. Uses the supplied {@link ScriptExecutor}
|
||||
* to invoke multiple SQL scripts in a particular directory.
|
||||
*
|
||||
* @author Matt Ward
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
public class ScriptBundleExecutorImpl implements ScriptBundleExecutor
|
||||
{
|
||||
private ScriptExecutor scriptExecutor;
|
||||
protected Log log = LogFactory.getLog(ScriptBundleExecutorImpl.class);
|
||||
|
||||
public ScriptBundleExecutorImpl(ScriptExecutor scriptExecutor)
|
||||
{
|
||||
this.scriptExecutor = scriptExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exec(boolean logOnly, String dir, String... scripts)
|
||||
{
|
||||
for (String name : scripts)
|
||||
{
|
||||
File file = new File(dir, name);
|
||||
try
|
||||
{
|
||||
scriptExecutor.executeScriptUrl(file.getPath());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
String msg = "Unable to run SQL script: dir=" + dir + ", name=" + name;
|
||||
if (logOnly)
|
||||
{
|
||||
log.error(msg, e);
|
||||
// Do not run any more scripts.
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Client opted to rethrow
|
||||
throw new AlfrescoRuntimeException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exec(String dir, String... scripts)
|
||||
{
|
||||
this.exec(true, dir, scripts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execWithPostScript(String dir, String postScript, String... scripts)
|
||||
{
|
||||
try
|
||||
{
|
||||
exec(true, dir, scripts);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Always run the post-script.
|
||||
exec(true, dir, postScript);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user