appliedPatches = patchService.getPatches(before, after);
// don't report anything if nothing was done
if (appliedPatches.size() == 0)
@@ -101,7 +101,7 @@ public class PatchExecuter extends AbstractLifecycleBean
{
boolean succeeded = true;
// list all patches applied, including failures
- for (PatchInfo patchInfo : appliedPatches)
+ for (AppliedPatch patchInfo : appliedPatches)
{
if (!patchInfo.getWasExecuted())
{
diff --git a/source/java/org/alfresco/repo/admin/patch/PatchService.java b/source/java/org/alfresco/repo/admin/patch/PatchService.java
index 7a2e2a2545..29394ff64b 100644
--- a/source/java/org/alfresco/repo/admin/patch/PatchService.java
+++ b/source/java/org/alfresco/repo/admin/patch/PatchService.java
@@ -27,8 +27,6 @@ package org.alfresco.repo.admin.patch;
import java.util.Date;
import java.util.List;
-import org.alfresco.error.AlfrescoRuntimeException;
-
/**
* Manages patches applied against the repository.
*
@@ -73,5 +71,5 @@ public interface PatchService
* the end date of the search, or null to g
* @return Returns all applied patches (successful or not)
*/
- public List getPatches(Date fromDate, Date toDate);
+ public List getPatches(Date fromDate, Date toDate);
}
diff --git a/source/java/org/alfresco/repo/admin/patch/PatchServiceImpl.java b/source/java/org/alfresco/repo/admin/patch/PatchServiceImpl.java
index 69a1615312..3d4b97dec4 100644
--- a/source/java/org/alfresco/repo/admin/patch/PatchServiceImpl.java
+++ b/source/java/org/alfresco/repo/admin/patch/PatchServiceImpl.java
@@ -32,8 +32,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.springframework.extensions.surf.util.I18NUtil;
-import org.alfresco.repo.domain.AppliedPatch;
+import org.alfresco.repo.domain.patch.AppliedPatchDAO;
import org.alfresco.repo.transaction.TransactionServiceImpl;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.admin.PatchException;
@@ -42,6 +41,7 @@ import org.alfresco.service.descriptor.Descriptor;
import org.alfresco.service.descriptor.DescriptorService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.extensions.surf.util.I18NUtil;
/**
@@ -68,7 +68,7 @@ public class PatchServiceImpl implements PatchService
private DescriptorService descriptorService;
private TransactionServiceImpl transactionService;
private RuleService ruleService;
- private PatchDaoService patchDaoService;
+ private AppliedPatchDAO appliedPatchDAO;
private List patches;
public PatchServiceImpl()
@@ -86,9 +86,9 @@ public class PatchServiceImpl implements PatchService
this.transactionService = transactionService;
}
- public void setPatchDaoService(PatchDaoService patchDaoService)
+ public void setAppliedPatchDAO(AppliedPatchDAO appliedPatchDAO)
{
- this.patchDaoService = patchDaoService;
+ this.appliedPatchDAO = appliedPatchDAO;
}
public void setRuleService(RuleService ruleService)
@@ -139,7 +139,7 @@ public class PatchServiceImpl implements PatchService
// construct a list of executed patches by ID (also check the date)
Map appliedPatchesById = new HashMap(23);
- List appliedPatches = patchDaoService.getAppliedPatches();
+ List appliedPatches = appliedPatchDAO.getAppliedPatches();
for (final AppliedPatch appliedPatch : appliedPatches)
{
appliedPatchesById.put(appliedPatch.getId(), appliedPatch);
@@ -153,7 +153,8 @@ public class PatchServiceImpl implements PatchService
public Date execute() throws Throwable
{
Date now = new Date();
- patchDaoService.setAppliedOnDate(appliedPatch.getId(), now);
+ appliedPatch.setAppliedOnDate(now);
+ appliedPatchDAO.updateAppliedPatch(appliedPatch);
return now;
}
};
@@ -255,7 +256,7 @@ public class PatchServiceImpl implements PatchService
" Patch: " + patch);
}
// get the patch from the DAO
- AppliedPatch appliedPatch = patchDaoService.getAppliedPatch(patch.getId());
+ AppliedPatch appliedPatch = appliedPatchDAO.getAppliedPatch(patch.getId());
// We bypass the patch if it was executed successfully
if (appliedPatch != null && !forcePatch)
{
@@ -316,9 +317,17 @@ public class PatchServiceImpl implements PatchService
String server = (serverDescriptor.getVersion() + " - " + serverDescriptor.getEdition());
// create or update the record of execution
+ boolean create = true;
if (appliedPatch == null)
{
- appliedPatch = patchDaoService.newAppliedPatch(patch.getId());
+ appliedPatch = new AppliedPatch();
+ appliedPatch.setId(patch.getId());
+ create = true;
+ }
+ else
+ {
+ // Update it
+ create = false;
}
// fill in the record's details
String patchDescription = I18NUtil.getMessage(patch.getDescription());
@@ -337,6 +346,15 @@ public class PatchServiceImpl implements PatchService
appliedPatch.setSucceeded(success); // whether or not the patch succeeded
appliedPatch.setWasExecuted(applies); // whether or not the patch was executed
appliedPatch.setReport(report); // additional, human-readable, status
+ // Update or create the entry
+ if (create)
+ {
+ appliedPatchDAO.createAppliedPatch(appliedPatch);
+ }
+ else
+ {
+ appliedPatchDAO.updateAppliedPatch(appliedPatch);
+ }
// done
if (logger.isDebugEnabled())
@@ -359,7 +377,7 @@ public class PatchServiceImpl implements PatchService
for (Patch alternative : alternatives)
{
// If the patch was executed, then this one was effectively executed
- AppliedPatch appliedAlternative = patchDaoService.getAppliedPatch(alternative.getId());
+ AppliedPatch appliedAlternative = appliedPatchDAO.getAppliedPatch(alternative.getId());
if (appliedAlternative != null && appliedAlternative.getSucceeded())
{
return alternative.getId();
@@ -392,7 +410,7 @@ public class PatchServiceImpl implements PatchService
}
@SuppressWarnings("unchecked")
- public List getPatches(Date fromDate, Date toDate)
+ public List getPatches(Date fromDate, Date toDate)
{
if (fromDate == null)
{
@@ -402,14 +420,9 @@ public class PatchServiceImpl implements PatchService
{
toDate = INFINITE_DATE;
}
- List extends PatchInfo> appliedPatches = patchDaoService.getAppliedPatches(fromDate, toDate);
- // disconnect each of these
- for (PatchInfo appliedPatch : appliedPatches)
- {
- patchDaoService.detach((AppliedPatch)appliedPatch);
- }
+ List extends AppliedPatch> appliedPatches = appliedPatchDAO.getAppliedPatches(fromDate, toDate);
// done
- return (List) appliedPatches;
+ return (List) appliedPatches;
}
/**
diff --git a/source/java/org/alfresco/repo/admin/patch/PatchTest.java b/source/java/org/alfresco/repo/admin/patch/PatchTest.java
index 1b55bf4805..ddf6917cfc 100644
--- a/source/java/org/alfresco/repo/admin/patch/PatchTest.java
+++ b/source/java/org/alfresco/repo/admin/patch/PatchTest.java
@@ -1,198 +1,188 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.admin.patch;
-
-import java.util.Date;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.alfresco.error.AlfrescoRuntimeException;
-import org.alfresco.repo.domain.AppliedPatch;
-import org.alfresco.repo.security.authentication.AuthenticationContext;
-import org.alfresco.service.cmr.admin.PatchException;
-import org.alfresco.service.cmr.repository.NodeService;
-import org.alfresco.service.cmr.search.SearchService;
-import org.alfresco.service.namespace.NamespaceService;
-import org.alfresco.service.transaction.TransactionService;
-import org.alfresco.util.ApplicationContextHelper;
-import org.springframework.context.ApplicationContext;
-
-/**
- * @see org.alfresco.repo.admin.patch.Patch
- * @see org.alfresco.repo.admin.patch.AbstractPatch
- * @see org.alfresco.repo.admin.patch.PatchService
- *
- * @author Derek Hulley
- */
-public class PatchTest extends TestCase
-{
- private static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
-
- private TransactionService transactionService;
- private NamespaceService namespaceService;
- private NodeService nodeService;
- private SearchService searchService;
- private AuthenticationContext authenticationContext;
- private PatchService patchService;
- private PatchDaoService patchDaoComponent;
-
- public PatchTest(String name)
- {
- super(name);
- }
-
- public void setUp() throws Exception
- {
- transactionService = (TransactionService) ctx.getBean("transactionComponent");
- namespaceService = (NamespaceService) ctx.getBean("namespaceService");
- nodeService = (NodeService) ctx.getBean("nodeService");
- searchService = (SearchService) ctx.getBean("searchService");
- authenticationContext = (AuthenticationContext) ctx.getBean("authenticationContext");
-
- patchService = (PatchService) ctx.getBean("PatchService");
- patchDaoComponent = (PatchDaoService) ctx.getBean("patchDaoComponent");
-
- // get the patches to play with
- patchService.registerPatch((Patch)ctx.getBean("patch.sample.02"));
- patchService.registerPatch((Patch)ctx.getBean("patch.sample.01"));
- }
-
- public void testSetup() throws Exception
- {
- assertNotNull(transactionService);
- assertNotNull(patchService);
- assertNotNull(patchDaoComponent);
- }
-
- private SamplePatch constructSamplePatch(boolean mustFail)
- {
- SamplePatch patch = new SamplePatch(mustFail, transactionService);
- patch.setNamespaceService(namespaceService);
- patch.setNodeService(nodeService);
- patch.setSearchService(searchService);
- patch.setAuthenticationContext(authenticationContext);
- // done
- return patch;
- }
-
- public void testSimplePatchSuccess() throws Exception
- {
- Patch patch = constructSamplePatch(false);
- String report = patch.apply();
- // check that the report was generated
- assertEquals("Patch report incorrect", SamplePatch.MSG_SUCCESS, report);
- }
-
- public void testPatchReapplication()
- {
- // successfully apply a patch
- Patch patch = constructSamplePatch(false);
- patch.apply();
- // check that the patch cannot be reapplied
- try
- {
- patch.apply();
- fail("AbstractPatch failed to prevent reapplication");
- }
- catch (AlfrescoRuntimeException e)
- {
- // expected
- }
-
- // apply an unsuccessful patch
- patch = constructSamplePatch(true);
- try
- {
- patch.apply();
- fail("Failed patch didn't throw PatchException");
- }
- catch (PatchException e)
- {
- // expected
- }
- // repeat
- try
- {
- patch.apply();
- fail("Reapplication of failed patch didn't throw PatchException");
- }
- catch (PatchException e)
- {
- // expected
- }
- }
-
- public void testApplyOutstandingPatches() throws Exception
- {
- // apply outstanding patches
- boolean success = patchService.applyOutstandingPatches();
- assertTrue(success);
- // get applied patches
- List appliedPatches = patchDaoComponent.getAppliedPatches();
- // check that the patch application was recorded
- boolean found01 = false;
- boolean found02 = false;
- for (AppliedPatch appliedPatch : appliedPatches)
- {
- if (appliedPatch.getId().equals("Sample01"))
- {
- found01 = true;
- assertTrue("Patch info didn't indicate success: " + appliedPatch, appliedPatch.getSucceeded());
- }
- else if (appliedPatch.getId().equals("Sample02"))
- {
- found02 = true;
- assertTrue("Patch info didn't indicate success: " + appliedPatch, appliedPatch.getSucceeded());
- }
- }
- assertTrue("Sample 01 not in list of applied patches", found01);
- assertTrue("Sample 02 not in list of applied patches", found02);
- }
-
- public void testGetPatchesByDate() throws Exception
- {
- // ensure that there are some applied patches
- testApplyOutstandingPatches();
- // get the number of applied patches
- List appliedPatches = patchDaoComponent.getAppliedPatches();
- assertTrue("Expected at least 2 applied patches", appliedPatches.size() >= 2);
-
- // now requery using null dates
- List appliedPatchesAllDates = patchService.getPatches(null, null);
- assertEquals("Applied patches by all dates doesn't match all applied patches",
- appliedPatches.size(), appliedPatchesAllDates.size());
-
- // make sure that the objects are not connected to the persistence layer
- PatchInfo disconnectedObject = appliedPatchesAllDates.get(0);
- AppliedPatch persistedObject = patchDaoComponent.getAppliedPatch(disconnectedObject.getId());
- assertNotSame("Instances should not be shared between evicted and cached objects",
- disconnectedObject, persistedObject);
-
- // perform another query with dates that should return no results
- List appliedPatchesFutureDates = patchService.getPatches(new Date(), new Date());
- assertEquals("Query returned results for dates when no patches should exist", 0, appliedPatchesFutureDates.size());
- }
-}
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.admin.patch;
+
+import java.util.Date;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.alfresco.error.AlfrescoRuntimeException;
+import org.alfresco.repo.security.authentication.AuthenticationContext;
+import org.alfresco.service.cmr.admin.PatchException;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.service.cmr.search.SearchService;
+import org.alfresco.service.namespace.NamespaceService;
+import org.alfresco.service.transaction.TransactionService;
+import org.alfresco.util.ApplicationContextHelper;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * @see org.alfresco.repo.admin.patch.Patch
+ * @see org.alfresco.repo.admin.patch.AbstractPatch
+ * @see org.alfresco.repo.admin.patch.PatchService
+ *
+ * @author Derek Hulley
+ */
+public class PatchTest extends TestCase
+{
+ private static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
+
+ private TransactionService transactionService;
+ private NamespaceService namespaceService;
+ private NodeService nodeService;
+ private SearchService searchService;
+ private AuthenticationContext authenticationContext;
+ private PatchService patchService;
+
+ public PatchTest(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ transactionService = (TransactionService) ctx.getBean("transactionComponent");
+ namespaceService = (NamespaceService) ctx.getBean("namespaceService");
+ nodeService = (NodeService) ctx.getBean("nodeService");
+ searchService = (SearchService) ctx.getBean("searchService");
+ authenticationContext = (AuthenticationContext) ctx.getBean("authenticationContext");
+
+ patchService = (PatchService) ctx.getBean("PatchService");
+
+ // get the patches to play with
+ patchService.registerPatch((Patch)ctx.getBean("patch.sample.02"));
+ patchService.registerPatch((Patch)ctx.getBean("patch.sample.01"));
+ }
+
+ public void testSetup() throws Exception
+ {
+ assertNotNull(transactionService);
+ assertNotNull(patchService);
+ }
+
+ private SamplePatch constructSamplePatch(boolean mustFail)
+ {
+ SamplePatch patch = new SamplePatch(mustFail, transactionService);
+ patch.setNamespaceService(namespaceService);
+ patch.setNodeService(nodeService);
+ patch.setSearchService(searchService);
+ patch.setAuthenticationContext(authenticationContext);
+ // done
+ return patch;
+ }
+
+ public void testSimplePatchSuccess() throws Exception
+ {
+ Patch patch = constructSamplePatch(false);
+ String report = patch.apply();
+ // check that the report was generated
+ assertEquals("Patch report incorrect", SamplePatch.MSG_SUCCESS, report);
+ }
+
+ public void testPatchReapplication()
+ {
+ // successfully apply a patch
+ Patch patch = constructSamplePatch(false);
+ patch.apply();
+ // check that the patch cannot be reapplied
+ try
+ {
+ patch.apply();
+ fail("AbstractPatch failed to prevent reapplication");
+ }
+ catch (AlfrescoRuntimeException e)
+ {
+ // expected
+ }
+
+ // apply an unsuccessful patch
+ patch = constructSamplePatch(true);
+ try
+ {
+ patch.apply();
+ fail("Failed patch didn't throw PatchException");
+ }
+ catch (PatchException e)
+ {
+ // expected
+ }
+ // repeat
+ try
+ {
+ patch.apply();
+ fail("Reapplication of failed patch didn't throw PatchException");
+ }
+ catch (PatchException e)
+ {
+ // expected
+ }
+ }
+
+ public void testApplyOutstandingPatches() throws Exception
+ {
+ // apply outstanding patches
+ boolean success = patchService.applyOutstandingPatches();
+ assertTrue(success);
+ // get applied patches
+ List appliedPatches = patchService.getPatches(null, null);
+ // check that the patch application was recorded
+ boolean found01 = false;
+ boolean found02 = false;
+ for (AppliedPatch appliedPatch : appliedPatches)
+ {
+ if (appliedPatch.getId().equals("Sample01"))
+ {
+ found01 = true;
+ assertTrue("Patch info didn't indicate success: " + appliedPatch, appliedPatch.getSucceeded());
+ }
+ else if (appliedPatch.getId().equals("Sample02"))
+ {
+ found02 = true;
+ assertTrue("Patch info didn't indicate success: " + appliedPatch, appliedPatch.getSucceeded());
+ }
+ }
+ assertTrue("Sample 01 not in list of applied patches", found01);
+ assertTrue("Sample 02 not in list of applied patches", found02);
+ }
+
+ public void testGetPatchesByDate() throws Exception
+ {
+ // ensure that there are some applied patches
+ testApplyOutstandingPatches();
+ // get the number of applied patches
+ List appliedPatches = patchService.getPatches(null, null);
+ assertTrue("Expected at least 2 applied patches", appliedPatches.size() >= 2);
+
+ // now requery using null dates
+ List appliedPatchesAllDates = patchService.getPatches(null, null);
+ assertEquals("Applied patches by all dates doesn't match all applied patches",
+ appliedPatches.size(), appliedPatchesAllDates.size());
+
+ // perform another query with dates that should return no results
+ List appliedPatchesFutureDates = patchService.getPatches(new Date(), new Date());
+ assertEquals("Query returned results for dates when no patches should exist", 0, appliedPatchesFutureDates.size());
+ }
+}
diff --git a/source/java/org/alfresco/repo/admin/patch/hibernate/HibernatePatchDaoServiceImpl.java b/source/java/org/alfresco/repo/admin/patch/hibernate/HibernatePatchDaoServiceImpl.java
deleted file mode 100644
index f7f603b854..0000000000
--- a/source/java/org/alfresco/repo/admin/patch/hibernate/HibernatePatchDaoServiceImpl.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.admin.patch.hibernate;
-
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import org.alfresco.error.AlfrescoRuntimeException;
-import org.alfresco.repo.admin.patch.PatchDaoService;
-import org.alfresco.repo.domain.AppliedPatch;
-import org.alfresco.repo.domain.hibernate.AppliedPatchImpl;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.springframework.orm.hibernate3.HibernateCallback;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-
-/**
- * Hibernate-specific implementation for managing patch persistence.
- *
- * @since 1.2
- * @author Derek Hulley
- */
-public class HibernatePatchDaoServiceImpl extends HibernateDaoSupport implements PatchDaoService
-{
- public static final String QUERY_GET_ALL_APPLIED_PATCHES = "patch.GetAllAppliedPatches";
- public static final String QUERY_GET_APPLIED_PATCHES_BY_DATE = "patch.GetAppliedPatchesByDate";
-
- public AppliedPatch newAppliedPatch(String id)
- {
- // check for existence
- AppliedPatch existing = getAppliedPatch(id);
- if (existing != null)
- {
- throw new AlfrescoRuntimeException("An applied patch already exists: \n" +
- " id: " + id);
- }
- // construct a new one
- AppliedPatchImpl patch = new AppliedPatchImpl();
- patch.setId(id);
- // save this in hibernate
- getHibernateTemplate().save(patch);
- // done
- return patch;
- }
-
- public AppliedPatch getAppliedPatch(String id)
- {
- AppliedPatch patch = (AppliedPatch) getHibernateTemplate().get(AppliedPatchImpl.class, id);
- // done
- return patch;
- }
-
- public void detach(AppliedPatch appliedPatch)
- {
- getSession().evict(appliedPatch);
- }
-
- /**
- * @see #QUERY_GET_ALL_APPLIED_PATCHES
- */
- @SuppressWarnings("unchecked")
- public List getAppliedPatches()
- {
- HibernateCallback callback = new HibernateCallback()
- {
- public Object doInHibernate(Session session)
- {
- Query query = session.getNamedQuery(HibernatePatchDaoServiceImpl.QUERY_GET_ALL_APPLIED_PATCHES);
- return query.list();
- }
- };
- List queryResults = (List) getHibernateTemplate().execute(callback);
- // done
- return queryResults;
- }
-
- /**
- * @see #QUERY_GET_APPLIED_PATCHES_BY_DATE
- */
- @SuppressWarnings("unchecked")
- public List getAppliedPatches(final Date fromDate, final Date toDate)
- {
- HibernateCallback callback = new HibernateCallback()
- {
- public Object doInHibernate(Session session)
- {
- Query query = session.getNamedQuery(HibernatePatchDaoServiceImpl.QUERY_GET_ALL_APPLIED_PATCHES);
- return query.list();
- }
- };
- List queryResults = (List) getHibernateTemplate().execute(callback);
- // eliminate results that are out of range
- Iterator iterator = queryResults.iterator();
- while (iterator.hasNext())
- {
- AppliedPatch appliedPatch = iterator.next();
- Date appliedOnDate = appliedPatch.getAppliedOnDate();
- if (appliedOnDate != null &&
- (fromDate.compareTo(appliedOnDate) >= 0 || toDate.compareTo(appliedOnDate) <= 0))
- {
- // it is out of range
- iterator.remove();
- }
- }
- // done
- return queryResults;
- }
-
- public void setAppliedOnDate(String id, Date appliedOnDate)
- {
- AppliedPatch patch = (AppliedPatch) getHibernateTemplate().get(AppliedPatchImpl.class, id);
- patch.setAppliedOnDate(appliedOnDate);
- }
-}
diff --git a/source/java/org/alfresco/repo/domain/AppliedPatch.java b/source/java/org/alfresco/repo/domain/AppliedPatch.java
deleted file mode 100644
index 5f613f945e..0000000000
--- a/source/java/org/alfresco/repo/domain/AppliedPatch.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.domain;
-
-import java.util.Date;
-
-import org.alfresco.repo.admin.patch.PatchInfo;
-
-/**
- * Interface for persistent patch application information.
- *
- * @author Derek Hulley
- */
-public interface AppliedPatch extends PatchInfo
-{
- public void setId(String id);
-
- public void setDescription(String description);
-
- public void setFixesFromSchema(int version);
-
- public void setFixesToSchema(int version);
-
- public void setTargetSchema(int version);
-
- public void setAppliedToSchema(int version);
-
- public void setAppliedToServer(String server);
-
- public void setAppliedOnDate(Date date);
-
- public void setWasExecuted(boolean executed);
-
- public void setSucceeded(boolean succeeded);
-
- public void setReport(String report);
-}
diff --git a/source/java/org/alfresco/repo/domain/DomainTestSuite.java b/source/java/org/alfresco/repo/domain/DomainTestSuite.java
index d009a7f73c..e926c59f72 100644
--- a/source/java/org/alfresco/repo/domain/DomainTestSuite.java
+++ b/source/java/org/alfresco/repo/domain/DomainTestSuite.java
@@ -33,6 +33,7 @@ import org.alfresco.repo.domain.encoding.EncodingDAOTest;
import org.alfresco.repo.domain.hibernate.HibernateSessionHelperTest;
import org.alfresco.repo.domain.locks.LockDAOTest;
import org.alfresco.repo.domain.mimetype.MimetypeDAOTest;
+import org.alfresco.repo.domain.patch.AppliedPatchDAOTest;
/**
* Suite for domain-related tests.
@@ -55,6 +56,7 @@ public class DomainTestSuite extends TestSuite
suite.addTestSuite(QNameDAOTest.class);
suite.addTestSuite(PropertyValueTest.class);
suite.addTestSuite(AuditDAOTest.class);
+ suite.addTestSuite(AppliedPatchDAOTest.class);
return suite;
}
diff --git a/source/java/org/alfresco/repo/domain/patch/AbstractAppliedPatchDAOImpl.java b/source/java/org/alfresco/repo/domain/patch/AbstractAppliedPatchDAOImpl.java
new file mode 100644
index 0000000000..8b0e18b25a
--- /dev/null
+++ b/source/java/org/alfresco/repo/domain/patch/AbstractAppliedPatchDAOImpl.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.domain.patch;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import org.alfresco.repo.admin.patch.AppliedPatch;
+
+/**
+ * Abstract implementation for DAO alf_applied_patch.
+ *
+ * @author Derek Hulley
+ * @since 3.3
+ */
+public abstract class AbstractAppliedPatchDAOImpl implements AppliedPatchDAO
+{
+ public void createAppliedPatch(AppliedPatch appliedPatch)
+ {
+ AppliedPatchEntity entity = new AppliedPatchEntity(appliedPatch);
+ createAppliedPatchEntity(entity);
+ }
+
+ public void updateAppliedPatch(AppliedPatch appliedPatch)
+ {
+ AppliedPatchEntity entity = new AppliedPatchEntity(appliedPatch);
+ updateAppliedPatchEntity(entity);
+ }
+
+ public AppliedPatch getAppliedPatch(String id)
+ {
+ return getAppliedPatchEntity(id);
+ }
+
+ public List getAppliedPatches()
+ {
+ List entities = getAppliedPatchEntities();
+ List results = new ArrayList();
+ results.addAll(entities);
+ return results;
+ }
+
+ public List getAppliedPatches(Date from, Date to)
+ {
+ // Manual filter (no performance required)
+ List results = getAppliedPatches();
+ Iterator iterator = results.iterator();
+ while (iterator.hasNext())
+ {
+ AppliedPatch next = iterator.next();
+ Date appliedOn = next.getAppliedOnDate();
+ if (from != null && appliedOn != null && from.compareTo(appliedOn) >= 0)
+ {
+ iterator.remove();
+ continue;
+ }
+ if (to != null && appliedOn != null && to.compareTo(appliedOn) <= 0)
+ {
+ iterator.remove();
+ continue;
+ }
+ }
+ return results;
+ }
+
+ public void setAppliedOnDate(String id, Date appliedOnDate)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ protected abstract void createAppliedPatchEntity(AppliedPatchEntity entity);
+ protected abstract void updateAppliedPatchEntity(AppliedPatchEntity appliedPatch);
+ protected abstract AppliedPatchEntity getAppliedPatchEntity(String id);
+ protected abstract List getAppliedPatchEntities();
+}
diff --git a/source/java/org/alfresco/repo/admin/patch/PatchDaoService.java b/source/java/org/alfresco/repo/domain/patch/AppliedPatchDAO.java
similarity index 68%
rename from source/java/org/alfresco/repo/admin/patch/PatchDaoService.java
rename to source/java/org/alfresco/repo/domain/patch/AppliedPatchDAO.java
index 9773431a69..35944fc1c2 100644
--- a/source/java/org/alfresco/repo/admin/patch/PatchDaoService.java
+++ b/source/java/org/alfresco/repo/domain/patch/AppliedPatchDAO.java
@@ -22,48 +22,38 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
-package org.alfresco.repo.admin.patch;
+package org.alfresco.repo.domain.patch;
import java.util.Date;
import java.util.List;
-import org.alfresco.repo.domain.AppliedPatch;
+import org.alfresco.repo.admin.patch.AppliedPatch;
/**
- * Provides data access support for patch persistence.
+ * Provides data access support for patch persistence in alf_applied_patch.
*
- * @since 1.2
+ * @since 3.3
* @author Derek Hulley
*/
-public interface PatchDaoService
+public interface AppliedPatchDAO
{
/**
- * Creates and saves a new instance of the patch. This will not have all the mandatory
- * properties set - only the ID.
+ * Creates and saves a new instance of the patch.
*
- * @param id the unique key
- * @return Returns a new instance that can be manipulated
+ * @param patchInfo the patch ID and details
*/
- public AppliedPatch newAppliedPatch(String id);
+ public void createAppliedPatch(AppliedPatch appliedPatch);
+
+ public void updateAppliedPatch(AppliedPatch appliedPatch);
/**
* Retrieve an existing patch
*
* @param id the patch unique ID
- * @return Returns the patch instance or null if one has not been persisted
+ * @return Returns the patch instance or null if one has not been persisted
*/
public AppliedPatch getAppliedPatch(String id);
- /**
- * Detaches the given instance from the persistence engine. This will
- * ensure that any changes made to the java object do not get persisted,
- * allowing the objects to be passed out to external clients without any
- * concern of their lifecycle.
- *
- * @param appliedPatch the object to detach from persistence
- */
- public void detach(AppliedPatch appliedPatch);
-
/**
* Get a list of all applied patches
*
diff --git a/source/java/org/alfresco/repo/domain/patch/AppliedPatchDAOTest.java b/source/java/org/alfresco/repo/domain/patch/AppliedPatchDAOTest.java
new file mode 100644
index 0000000000..ceb8ef410e
--- /dev/null
+++ b/source/java/org/alfresco/repo/domain/patch/AppliedPatchDAOTest.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.domain.patch;
+
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.alfresco.repo.admin.patch.AppliedPatch;
+import org.alfresco.repo.transaction.RetryingTransactionHelper;
+import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
+import org.alfresco.service.ServiceRegistry;
+import org.alfresco.service.transaction.TransactionService;
+import org.alfresco.util.ApplicationContextHelper;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * @see AppliedPatchDAO
+ *
+ * @author Derek Hulley
+ * @since 3.3
+ */
+public class AppliedPatchDAOTest extends TestCase
+{
+ private ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
+
+ private TransactionService transactionService;
+ private RetryingTransactionHelper txnHelper;
+ private AppliedPatchDAO appliedPatchDAO;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
+ transactionService = serviceRegistry.getTransactionService();
+ txnHelper = transactionService.getRetryingTransactionHelper();
+
+ appliedPatchDAO = (AppliedPatchDAO) ctx.getBean("appliedPatchDAO");
+ }
+
+ private AppliedPatch create(String id, boolean allNull) throws Exception
+ {
+ final AppliedPatch appliedPatch = new AppliedPatchEntity();
+ appliedPatch.setId(id);
+ if (!allNull)
+ {
+ appliedPatch.setDescription(id);
+ appliedPatch.setFixesFromSchema(0);
+ appliedPatch.setFixesToSchema(1);
+ appliedPatch.setTargetSchema(2);
+ appliedPatch.setAppliedOnDate(new Date());
+ appliedPatch.setAppliedToSchema(1);
+ appliedPatch.setAppliedToServer("blah");
+ appliedPatch.setWasExecuted(true);
+ appliedPatch.setSucceeded(true);
+ appliedPatch.setReport("All good in test " + getName());
+ }
+ RetryingTransactionCallback callback = new RetryingTransactionCallback()
+ {
+ public Void execute() throws Throwable
+ {
+ appliedPatchDAO.createAppliedPatch(appliedPatch);
+ return null;
+ }
+ };
+ txnHelper.doInTransaction(callback);
+ return appliedPatch;
+ }
+
+ private AppliedPatch get(final String id) throws Exception
+ {
+ RetryingTransactionCallback callback = new RetryingTransactionCallback()
+ {
+ public AppliedPatch execute() throws Throwable
+ {
+ return appliedPatchDAO.getAppliedPatch(id);
+ }
+ };
+ return txnHelper.doInTransaction(callback);
+ }
+
+ public void testCreateEmpty() throws Exception
+ {
+ final String id = getName() + "-" + System.currentTimeMillis();
+ create(id, true);
+ }
+
+ public void testCreatePopulated() throws Exception
+ {
+ final String id = getName() + "-" + System.currentTimeMillis();
+ create(id, false);
+ }
+
+ public void testCreateWithRollback() throws Exception
+ {
+ final String id = getName() + "-" + System.currentTimeMillis();
+ // Create an encoding
+ RetryingTransactionCallback callback = new RetryingTransactionCallback()
+ {
+ public Void execute() throws Throwable
+ {
+ create(id, false);
+ // Now force a rollback
+ throw new RuntimeException("Forced");
+ }
+ };
+ try
+ {
+ txnHelper.doInTransaction(callback);
+ fail("Transaction didn't roll back");
+ }
+ catch (RuntimeException e)
+ {
+ // Expected
+ }
+ // Check that it doesn't exist
+ get(id);
+ }
+//
+// public void testCaseInsensitivity() throws Exception
+// {
+// String encoding = "AAA-" + GUID.generate();
+// Pair lowercasePair = get(encoding.toLowerCase(), true, true);
+// // Check that the same pair is retrievable using uppercase
+// Pair uppercasePair = get(encoding.toUpperCase(), true, true);
+// assertNotNull(uppercasePair);
+// assertEquals(
+// "Upper and lowercase encoding instance IDs were not the same",
+// lowercasePair.getFirst(), uppercasePair.getFirst());
+// }
+}
diff --git a/source/java/org/alfresco/repo/admin/patch/PatchInfo.java b/source/java/org/alfresco/repo/domain/patch/AppliedPatchEntity.java
similarity index 64%
rename from source/java/org/alfresco/repo/admin/patch/PatchInfo.java
rename to source/java/org/alfresco/repo/domain/patch/AppliedPatchEntity.java
index 3fe415c408..386dd95a14 100644
--- a/source/java/org/alfresco/repo/admin/patch/PatchInfo.java
+++ b/source/java/org/alfresco/repo/domain/patch/AppliedPatchEntity.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -22,36 +22,25 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
-package org.alfresco.repo.admin.patch;
+package org.alfresco.repo.domain.patch;
-import java.util.Date;
+import org.alfresco.repo.admin.patch.AppliedPatch;
/**
- * Data on applied patches
+ * Entity for alf_applied_patch persistence.
*
* @author Derek Hulley
+ * @since 3.3
*/
-public interface PatchInfo
+public class AppliedPatchEntity extends AppliedPatch
{
- public String getId();
-
- public String getDescription();
+ public AppliedPatchEntity()
+ {
+ super();
+ }
- public int getFixesFromSchema();
-
- public int getFixesToSchema();
-
- public int getTargetSchema();
-
- public int getAppliedToSchema();
-
- public String getAppliedToServer();
-
- public Date getAppliedOnDate();
-
- public boolean getWasExecuted();
-
- public boolean getSucceeded();
-
- public String getReport();
+ public AppliedPatchEntity(AppliedPatch appliedPatch)
+ {
+ super(appliedPatch);
+ }
}
diff --git a/source/java/org/alfresco/repo/domain/patch/ibatis/AppliedPatchDAOImpl.java b/source/java/org/alfresco/repo/domain/patch/ibatis/AppliedPatchDAOImpl.java
new file mode 100644
index 0000000000..b368efdb54
--- /dev/null
+++ b/source/java/org/alfresco/repo/domain/patch/ibatis/AppliedPatchDAOImpl.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.domain.patch.ibatis;
+
+import java.util.List;
+
+import org.alfresco.repo.domain.patch.AbstractAppliedPatchDAOImpl;
+import org.alfresco.repo.domain.patch.AppliedPatchEntity;
+import org.springframework.orm.ibatis.SqlMapClientTemplate;
+
+/**
+ * iBatis-specific implementation of the AppliedPatch DAO.
+ *
+ * @author Derek Hulley
+ * @since 3.3
+ */
+public class AppliedPatchDAOImpl extends AbstractAppliedPatchDAOImpl
+{
+ private static final String INSERT_APPLIED_PATCH = "alfresco.appliedpatch.insert_AppliedPatch";
+ private static final String UPDATE_APPLIED_PATCH = "alfresco.appliedpatch.update_AppliedPatch";
+ private static final String SELECT_APPLIED_PATCH_BY_ID = "alfresco.appliedpatch.select_AppliedPatchById";
+ private static final String SELECT_ALL_APPLIED_PATCH = "alfresco.appliedpatch.select_AllAppliedPatches";
+
+ private SqlMapClientTemplate template;
+
+ public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate)
+ {
+ this.template = sqlMapClientTemplate;
+ }
+
+ @Override
+ protected void createAppliedPatchEntity(AppliedPatchEntity entity)
+ {
+ template.insert(INSERT_APPLIED_PATCH, entity);
+ }
+
+ public void updateAppliedPatchEntity(AppliedPatchEntity appliedPatch)
+ {
+ template.update(UPDATE_APPLIED_PATCH, appliedPatch);
+ }
+
+ @Override
+ protected AppliedPatchEntity getAppliedPatchEntity(String id)
+ {
+ AppliedPatchEntity entity = new AppliedPatchEntity();
+ entity.setId(id);
+ entity = (AppliedPatchEntity) template.queryForObject(SELECT_APPLIED_PATCH_BY_ID, entity);
+ // Could be null
+ return entity;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected List getAppliedPatchEntities()
+ {
+ return (List) template.queryForList(SELECT_ALL_APPLIED_PATCH);
+ }
+
+
+//
+// @Override
+// protected EncodingEntity getEncodingEntity(Long id)
+// {
+// EncodingEntity encodingEntity = new EncodingEntity();
+// encodingEntity.setId(id);
+// encodingEntity = (EncodingEntity) template.queryForObject(SELECT_ENCODING_BY_ID, encodingEntity);
+// // Done
+// return encodingEntity;
+// }
+//
+// @Override
+// protected EncodingEntity getEncodingEntity(String encoding)
+// {
+// EncodingEntity encodingEntity = new EncodingEntity();
+// encodingEntity.setEncoding(encoding == null ? null : encoding.toLowerCase());
+// encodingEntity = (EncodingEntity) template.queryForObject(SELECT_ENCODING_BY_KEY, encodingEntity);
+// // Could be null
+// return encodingEntity;
+// }
+//
+// @Override
+// protected EncodingEntity createEncodingEntity(String encoding)
+// {
+// EncodingEntity encodingEntity = new EncodingEntity();
+// encodingEntity.setVersion(MimetypeEntity.CONST_LONG_ZERO);
+// encodingEntity.setEncoding(encoding == null ? null : encoding.toLowerCase());
+// Long id = (Long) template.insert(INSERT_ENCODING, encodingEntity);
+// encodingEntity.setId(id);
+// // Done
+// return encodingEntity;
+// }
+}
diff --git a/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java b/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java
index 49d65ab53f..5eaade653e 100644
--- a/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java
+++ b/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java
@@ -43,37 +43,37 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl
private static final String SELECT_AVM_LD_NODE_ENTITIES_NULL_VERSION = "alfresco.avm.select_AVMNodes_nullVersionLayeredDirectories";
private static final String SELECT_AVM_LF_NODE_ENTITIES_NULL_VERSION = "alfresco.avm.select_AVMNodes_nullVersionLayeredFiles";
- private SqlMapClientTemplate avmTemplate;
+ private SqlMapClientTemplate template;
- public void setAvmSqlMapClientTemplate(SqlMapClientTemplate avmSqlMapClientTemplate)
+ public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate)
{
- this.avmTemplate = avmSqlMapClientTemplate;
+ this.template = sqlMapClientTemplate;
}
-
+
@Override
protected Long getAVMNodeEntitiesCountWhereNewInStore()
{
- return (Long) avmTemplate.queryForObject(SELECT_AVM_NODE_ENTITIES_COUNT_WHERE_NEW_IN_STORE);
+ return (Long) template.queryForObject(SELECT_AVM_NODE_ENTITIES_COUNT_WHERE_NEW_IN_STORE);
}
@SuppressWarnings("unchecked")
@Override
protected List getAVMNodeEntitiesWithEmptyGUID()
{
- return (List) avmTemplate.queryForList(SELECT_AVM_NODE_ENTITIES_WITH_EMPTY_GUID);
+ return (List) template.queryForList(SELECT_AVM_NODE_ENTITIES_WITH_EMPTY_GUID);
}
@SuppressWarnings("unchecked")
@Override
protected List getNullVersionLayeredDirectoryNodeEntities()
{
- return (List) avmTemplate.queryForList(SELECT_AVM_LD_NODE_ENTITIES_NULL_VERSION);
+ return (List) template.queryForList(SELECT_AVM_LD_NODE_ENTITIES_NULL_VERSION);
}
@SuppressWarnings("unchecked")
@Override
protected List getNullVersionLayeredFileNodeEntities()
{
- return (List) avmTemplate.queryForList(SELECT_AVM_LF_NODE_ENTITIES_NULL_VERSION);
+ return (List) template.queryForList(SELECT_AVM_LF_NODE_ENTITIES_NULL_VERSION);
}
}
diff --git a/source/java/org/alfresco/repo/importer/system/SystemExporterImporter.java b/source/java/org/alfresco/repo/importer/system/SystemExporterImporter.java
index 575ca243ca..fcbb59161c 100644
--- a/source/java/org/alfresco/repo/importer/system/SystemExporterImporter.java
+++ b/source/java/org/alfresco/repo/importer/system/SystemExporterImporter.java
@@ -28,8 +28,8 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
-import org.alfresco.repo.admin.patch.PatchDaoService;
-import org.alfresco.repo.domain.AppliedPatch;
+import org.alfresco.repo.admin.patch.AppliedPatch;
+import org.alfresco.repo.domain.patch.AppliedPatchDAO;
import org.alfresco.repo.version.common.counter.VersionCounterService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
@@ -44,7 +44,7 @@ public class SystemExporterImporter
{
// dependencies
private NodeService nodeService;
- private PatchDaoService patchDao;
+ private AppliedPatchDAO appliedPatchDAO;
private VersionCounterService versionCounterService;
@@ -53,9 +53,9 @@ public class SystemExporterImporter
this.nodeService = nodeService;
}
- public void setPatchDao(PatchDaoService patchDaoService)
+ public void setAppliedPatchDAO(AppliedPatchDAO appliedPatchDAO)
{
- this.patchDao = patchDaoService;
+ this.appliedPatchDAO = appliedPatchDAO;
}
public void setVersionCounterService(VersionCounterService versionCounterService)
@@ -74,7 +74,7 @@ public class SystemExporterImporter
SystemInfo systemInfo = new SystemInfo();
// capture applied patches
- List patches = patchDao.getAppliedPatches();
+ List patches = appliedPatchDAO.getAppliedPatches();
for (AppliedPatch patch : patches)
{
PatchInfo patchInfo = new PatchInfo();
@@ -119,7 +119,8 @@ public class SystemExporterImporter
// apply patch info
for (PatchInfo patchInfo : systemInfo.patches)
{
- AppliedPatch patch = patchDao.newAppliedPatch(patchInfo.id);
+ AppliedPatch patch = new AppliedPatch();
+ patch.setId(patchInfo.id);
patch.setAppliedOnDate(patchInfo.appliedOnDate);
patch.setAppliedToSchema(patchInfo.appliedToSchema);
patch.setAppliedToServer(patchInfo.appliedToServer);
@@ -130,6 +131,7 @@ public class SystemExporterImporter
patch.setSucceeded(patchInfo.succeeded);
patch.setTargetSchema(patchInfo.targetSchema);
patch.setWasExecuted(patchInfo.wasExecuted);
+ appliedPatchDAO.createAppliedPatch(patch);
}
// apply version counters