Merged V2.0 to HEAD

svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@5154 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@5155 .
      - Installer script cleanup
   svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@5156 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@5157 .
   svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@5162 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@5163 .
   svn rm --force root\projects\repository\config\alfresco\dbscripts\create\1.4\org.hibernate.dialect.Dialect\post-create-indexes.sql
   svn rm --force root\projects\repository\config\alfresco\dbscripts\create\1.4\org.hibernate.dialect.MySQLInnoDBDialect\post-create-indexes.sql
      - Fix AR-1225: Upgrade and install indexes


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5171 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-02-16 16:10:44 +00:00
parent f484e98638
commit b4e48157f5
15 changed files with 294 additions and 105 deletions

View File

@@ -72,11 +72,12 @@ public interface PatchDaoService
public List<AppliedPatch> getAppliedPatches();
/**
* Get a list of all patches applied between the given dates
* Get a list of all patches applied between the given dates.
*
* @param from the lower date limit or null to ignore
* @param to the upper date limit or null to ignore
* @return Returns all applied patches
* @return Returns applied patches for the date range, but also patches without
* a date
*/
public List<AppliedPatch> getAppliedPatches(Date from, Date to);
}

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.admin.patch;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -94,40 +96,46 @@ public class PatchServiceImpl implements PatchService
try
{
// Diable rules whilst processing the patches
this.ruleService.disableRules();
try
{
// construct a map of all known patches by ID
Map<String, Patch> allPatchesById = new HashMap<String, Patch>(23);
for (Patch patch : patches)
// Disable rules whilst processing the patches
this.ruleService.disableRules();
try
{
allPatchesById.put(patch.getId(), patch);
}
// construct a list of executed patches by ID
Map<String, AppliedPatch> appliedPatchesById = new HashMap<String, AppliedPatch>(23);
List<AppliedPatch> appliedPatches = patchDaoService.getAppliedPatches();
for (AppliedPatch appliedPatch : appliedPatches)
{
appliedPatchesById.put(appliedPatch.getId(), appliedPatch);
}
// go through all the patches and apply them where necessary
for (Patch patch : allPatchesById.values())
{
// apply the patch
success = applyPatchAndDependencies(patch, appliedPatchesById);
if (!success)
// Sort the patches
List<Patch> sortedPatches = new ArrayList<Patch>(patches);
Comparator<Patch> comparator = new PatchTargetSchemaComparator();
Collections.sort(sortedPatches, comparator);
// construct a list of executed patches by ID (also check the date)
Map<String, AppliedPatch> appliedPatchesById = new HashMap<String, AppliedPatch>(23);
List<AppliedPatch> appliedPatches = patchDaoService.getAppliedPatches();
for (AppliedPatch appliedPatch : appliedPatches)
{
// we failed to apply a patch or one of its dependencies - terminate
break;
appliedPatchesById.put(appliedPatch.getId(), appliedPatch);
// Update the time of execution if it is null. This is to deal with
// patches that get executed prior to server startup and need to have
// an execution time assigned
if (appliedPatch.getAppliedOnDate() == null)
{
appliedPatch.setAppliedOnDate(new Date());
}
}
}
}
finally
{
this.ruleService.enableRules();
}
// go through all the patches and apply them where necessary
for (Patch patch : sortedPatches)
{
// apply the patch
success = applyPatchAndDependencies(patch, appliedPatchesById);
if (!success)
{
// we failed to apply a patch or one of its dependencies - terminate
break;
}
}
}
finally
{
this.ruleService.enableRules();
}
}
catch (Throwable exception)
{
@@ -306,4 +314,21 @@ public class PatchServiceImpl implements PatchService
// done
return (List<PatchInfo>) appliedPatches;
}
/**
* Compares patch target schemas.
*
* @see Patch#getTargetSchema()
* @author Derek Hulley
*/
private static class PatchTargetSchemaComparator implements Comparator<Patch>
{
public int compare(Patch p1, Patch p2)
{
Integer i1 = new Integer(p1.getTargetSchema());
Integer i2 = new Integer(p2.getTargetSchema());
return i1.compareTo(i2);
}
}
}

View File

@@ -118,7 +118,7 @@ public class HibernatePatchDaoServiceImpl extends HibernateDaoSupport implements
{
AppliedPatch appliedPatch = iterator.next();
Date appliedOnDate = appliedPatch.getAppliedOnDate();
if (fromDate.compareTo(appliedOnDate) >= 0 || toDate.compareTo(appliedOnDate) <= 0)
if (appliedOnDate != null && fromDate.compareTo(appliedOnDate) >= 0 || toDate.compareTo(appliedOnDate) <= 0)
{
// it is out of range
iterator.remove();