use of org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch in project alfresco-repository by Alfresco.
the class SchemaBootstrap method checkSchemaPatchScripts.
/**
* Check that the necessary scripts have been executed against the database
*/
private void checkSchemaPatchScripts(Connection connection, List<SchemaUpgradeScriptPatch> scriptPatches, boolean apply) throws Exception {
// first check if there have been any applied patches
int appliedPatchCount = countAppliedPatches(connection);
if (appliedPatchCount == 0) {
// and patches will not have been applied yet
return;
}
ensureCurrentClusterMemberIsBootstrapping(connection);
// Retrieve the first installed schema number
int installedSchema = getInstalledSchemaNumber(connection);
nextPatch: for (SchemaUpgradeScriptPatch patch : scriptPatches) {
final String patchId = patch.getId();
final String scriptUrl = patch.getScriptUrl();
// Check if any of the alternative patches were executed
List<Patch> alternatives = patch.getAlternatives();
for (Patch alternativePatch : alternatives) {
String alternativePatchId = alternativePatch.getId();
boolean alternativeSucceeded = didPatchSucceed(connection, alternativePatchId, true);
if (alternativeSucceeded) {
continue nextPatch;
}
}
// check if the script was successfully executed
boolean wasSuccessfullyApplied = didPatchSucceed(connection, patchId, false);
if (wasSuccessfullyApplied) {
// with the patch bean present.
continue;
} else if (!patch.applies(installedSchema)) {
// Patch does not apply to the installed schema number
continue;
} else if (!apply) {
// the script was not run and may not be run automatically
throw AlfrescoRuntimeException.create(ERR_SCRIPT_NOT_RUN, scriptUrl);
}
// it wasn't run and it can be run now
executeScriptUrl(connection, scriptUrl);
}
}
use of org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch in project alfresco-repository by Alfresco.
the class SchemaBootstrapRegistration method register.
/**
* Registers all the necessary scripts and patches with the {@link SchemaBootstrap}.
*/
public void register() {
PropertyCheck.mandatory(this, "schemaBootstrap", schemaBootstrap);
PropertyCheck.mandatory(this, "preCreateScriptUrls", preCreateScriptUrls);
PropertyCheck.mandatory(this, "postCreateScriptUrls", postCreateScriptUrls);
PropertyCheck.mandatory(this, "preUpdateScriptPatches", preUpdateScriptPatches);
PropertyCheck.mandatory(this, "postUpdateScriptPatches", postUpdateScriptPatches);
PropertyCheck.mandatory(this, "updateActivitiScriptPatches", updateActivitiScriptPatches);
for (String preCreateScriptUrl : preCreateScriptUrls) {
schemaBootstrap.addPreCreateScriptUrl(preCreateScriptUrl);
}
for (String postCreateScriptUrl : postCreateScriptUrls) {
schemaBootstrap.addPostCreateScriptUrl(postCreateScriptUrl);
}
for (SchemaUpgradeScriptPatch preUpdateScriptPatch : preUpdateScriptPatches) {
schemaBootstrap.addPreUpdateScriptPatch(preUpdateScriptPatch);
}
for (SchemaUpgradeScriptPatch postUpdateScriptPatch : postUpdateScriptPatches) {
schemaBootstrap.addPostUpdateScriptPatch(postUpdateScriptPatch);
}
for (SchemaUpgradeScriptPatch updateActivitiScriptPatch : updateActivitiScriptPatches) {
schemaBootstrap.addUpdateActivitiScriptPatch(updateActivitiScriptPatch);
}
}
Aggregations