SAIL-232: AppliedPatch.hbm.xml

- Basic CREATE script for core tables: AlfrescoCreate-3.3-RepoTables.sql
 - Removed Hibernate control of alf_applied_patch


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18101 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2010-01-18 16:39:18 +00:00
parent 7f24c8c4e7
commit b96d174e1f
26 changed files with 941 additions and 696 deletions

View File

@@ -68,6 +68,7 @@
</property> </property>
<property name="preCreateScriptUrls"> <property name="preCreateScriptUrls">
<list> <list>
<value>classpath:alfresco/dbscripts/create/3.3/${db.script.dialect}/AlfrescoCreate-3.3-RepoTables.sql</value>
</list> </list>
</property> </property>
<property name="postCreateScriptUrls"> <property name="postCreateScriptUrls">

View File

@@ -15,6 +15,14 @@
<property name="sqlMapClient" ref="activitiesSqlMapClient"/> <property name="sqlMapClient" ref="activitiesSqlMapClient"/>
</bean> </bean>
<bean id="patchDAO" class="org.alfresco.repo.domain.patch.ibatis.PatchDAOImpl">
<property name="sqlMapClientTemplate" ref="repoSqlMapClientTemplate"/>
</bean>
<bean id="appliedPatchDAO" class="org.alfresco.repo.domain.patch.ibatis.AppliedPatchDAOImpl">
<property name="sqlMapClientTemplate" ref="repoSqlMapClientTemplate"/>
</bean>
<bean id="lockDAO" class="org.alfresco.repo.domain.locks.ibatis.LockDAOImpl"> <bean id="lockDAO" class="org.alfresco.repo.domain.locks.ibatis.LockDAOImpl">
<property name="sqlMapClientTemplate" ref="locksSqlMapClientTemplate"/> <property name="sqlMapClientTemplate" ref="locksSqlMapClientTemplate"/>
<property name="qnameDAO" ref="qnameDAO"/> <property name="qnameDAO" ref="qnameDAO"/>
@@ -67,48 +75,32 @@
<property name="propertyValueDAO" ref="propertyValueDAO"/> <property name="propertyValueDAO" ref="propertyValueDAO"/>
</bean> </bean>
<!-- AVM --> <!-- AVM -->
<bean id="newAvmStoreDAO" class="org.alfresco.repo.domain.avm.ibatis.AVMStoreDAOImpl"> <bean id="newAvmStoreDAO" class="org.alfresco.repo.domain.avm.ibatis.AVMStoreDAOImpl">
<property name="sqlMapClientTemplate" ref="avmSqlMapClientTemplate"/> <property name="sqlMapClientTemplate" ref="avmSqlMapClientTemplate"/>
<property name="qnameDAO" ref="qnameDAO"/>
<property name="qnameDAO" ref="qnameDAO"/> <property name="avmStoreCache" ref="avmStoreCache"/>
<property name="avmStorePropertyCache" ref="avmEntityCache"/>
<property name="avmStoreCache" ref="avmStoreCache"/> </bean>
<property name="avmStorePropertyCache" ref="avmEntityCache"/>
<bean id="newAvmNodeDAO" class="org.alfresco.repo.domain.avm.ibatis.AVMNodeDAOImpl">
</bean> <property name="sqlMapClientTemplate" ref="avmSqlMapClientTemplate"/>
<property name="qnameDAO" ref="qnameDAO"/>
<bean id="newAvmNodeDAO" class="org.alfresco.repo.domain.avm.ibatis.AVMNodeDAOImpl"> <property name="avmNodeCache" ref="avmNodeCache"/>
<property name="sqlMapClientTemplate" ref="avmSqlMapClientTemplate"/> <property name="avmNodePropertyCache" ref="avmEntityCache"/>
<property name="avmNodeAspectsCache" ref="avmNodeAspectsCache"/>
<property name="qnameDAO" ref="qnameDAO"/> </bean>
<property name="avmNodeCache" ref="avmNodeCache"/> <bean id="newAvmNodeLinksDAO" class="org.alfresco.repo.domain.avm.ibatis.AVMNodeLinksDAOImpl">
<property name="avmNodePropertyCache" ref="avmEntityCache"/> <property name="sqlMapClientTemplate" ref="avmSqlMapClientTemplate"/>
<property name="avmNodeAspectsCache" ref="avmNodeAspectsCache"/> <property name="avmChildEntryCache" ref="avmEntityCache"/>
<property name="avmHistoryLinkCache" ref="avmEntityCache"/>
</bean> </bean>
<bean id="newAvmNodeLinksDAO" class="org.alfresco.repo.domain.avm.ibatis.AVMNodeLinksDAOImpl"> <bean id="newAvmVersionRootDAO" class="org.alfresco.repo.domain.avm.ibatis.AVMVersionRootDAOImpl">
<property name="sqlMapClientTemplate" ref="avmSqlMapClientTemplate"/> <property name="sqlMapClientTemplate" ref="avmSqlMapClientTemplate"/>
<property name="versionRootEntityCache" ref="avmVersionRootEntityCache"/>
<property name="avmChildEntryCache" ref="avmEntityCache"/>
<property name="avmHistoryLinkCache" ref="avmEntityCache"/>
</bean>
<bean id="newAvmVersionRootDAO" class="org.alfresco.repo.domain.avm.ibatis.AVMVersionRootDAOImpl">
<property name="sqlMapClientTemplate" ref="avmSqlMapClientTemplate"/>
<property name="versionRootEntityCache" ref="avmVersionRootEntityCache"/>
</bean> </bean>
<!-- Patch -->
<bean id="patchDAO" class="org.alfresco.repo.domain.patch.ibatis.PatchDAOImpl">
<property name="avmSqlMapClientTemplate" ref="avmSqlMapClientTemplate"/>
</bean>
</beans> </beans>

View File

@@ -0,0 +1,24 @@
--
-- Title: Core Repository Tables
-- Database: MySQL InnoDB
-- Since: V3.3 Schema 4000
-- Author: Derek Hulley
--
-- Please contact support@alfresco.com if you need assistance with the upgrade.
--
CREATE TABLE alf_applied_patch
(
id VARCHAR(64) NOT NULL,
description TEXT,
fixes_from_schema INTEGER,
fixes_to_schema INTEGER,
applied_to_schema INTEGER,
target_schema INTEGER,
applied_on_date DATETIME,
applied_to_server VARCHAR(64),
was_executed BIT,
succeeded BIT,
report TEXT,
PRIMARY KEY (id)
) ENGINE=InnoDB;

View File

@@ -85,13 +85,6 @@
eternal="true" eternal="true"
overflowToDisk="false" overflowToDisk="false"
/> />
<!-- approx 0.1MB memory required -->
<cache
name="org.alfresco.repo.domain.hibernate.AppliedPatchImpl"
maxElementsInMemory="100"
timeToLiveSeconds="300"
overflowToDisk="false"
/>
<!-- Permission related caches --> <!-- Permission related caches -->
<!-- approx 1MB memory required --> <!-- approx 1MB memory required -->
<cache <cache

View File

@@ -200,23 +200,6 @@
replicateAsynchronously = false"/> replicateAsynchronously = false"/>
</cache> </cache>
<cache
name="org.alfresco.repo.domain.hibernate.AppliedPatchImpl"
maxElementsInMemory="100"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="300"
overflowToDisk="false">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicatePuts = false,
replicateUpdates = true,
replicateRemovals = true,
replicateUpdatesViaCopy = false,
replicateAsynchronously = false"/>
</cache>
<cache <cache
name="org.alfresco.repo.domain.hibernate.DbAccessControlEntryContextImpl" name="org.alfresco.repo.domain.hibernate.DbAccessControlEntryContextImpl"
maxElementsInMemory="1000" maxElementsInMemory="1000"

View File

@@ -61,7 +61,6 @@
<value>org/alfresco/repo/domain/hibernate/Node.hbm.xml</value> <value>org/alfresco/repo/domain/hibernate/Node.hbm.xml</value>
<value>org/alfresco/repo/domain/hibernate/Transaction.hbm.xml</value> <value>org/alfresco/repo/domain/hibernate/Transaction.hbm.xml</value>
<value>org/alfresco/repo/domain/hibernate/VersionCount.hbm.xml</value> <value>org/alfresco/repo/domain/hibernate/VersionCount.hbm.xml</value>
<value>org/alfresco/repo/domain/hibernate/AppliedPatch.hbm.xml</value>
<value>org/alfresco/repo/domain/hibernate/Permission.hbm.xml</value> <value>org/alfresco/repo/domain/hibernate/Permission.hbm.xml</value>
<value>org/alfresco/repo/attributes/hibernate/Attributes.hbm.xml</value> <value>org/alfresco/repo/attributes/hibernate/Attributes.hbm.xml</value>
<value>org/alfresco/repo/domain/hibernate/UsageDelta.hbm.xml</value> <value>org/alfresco/repo/domain/hibernate/UsageDelta.hbm.xml</value>
@@ -177,7 +176,6 @@
<prop key="org.alfresco.repo.domain.hibernate.TransactionImpl">${cache.strategy}</prop> <prop key="org.alfresco.repo.domain.hibernate.TransactionImpl">${cache.strategy}</prop>
<prop key="org.alfresco.repo.domain.hibernate.ServerImpl">${cache.strategy}</prop> <prop key="org.alfresco.repo.domain.hibernate.ServerImpl">${cache.strategy}</prop>
<prop key="org.alfresco.repo.domain.hibernate.VersionCountImpl">${cache.strategy}</prop> <prop key="org.alfresco.repo.domain.hibernate.VersionCountImpl">${cache.strategy}</prop>
<prop key="org.alfresco.repo.domain.hibernate.AppliedPatchImpl">${cache.strategy}</prop>
<prop key="org.alfresco.repo.domain.hibernate.DbAccessControlEntryContextImpl">${cache.strategy}</prop> <prop key="org.alfresco.repo.domain.hibernate.DbAccessControlEntryContextImpl">${cache.strategy}</prop>
<prop key="org.alfresco.repo.domain.hibernate.DbAccessControlEntryImpl">${cache.strategy}</prop> <prop key="org.alfresco.repo.domain.hibernate.DbAccessControlEntryImpl">${cache.strategy}</prop>

View File

@@ -10,6 +10,7 @@
<typeHandler javaType="java.io.Serializable" jdbcType="BLOB" callback="org.alfresco.ibatis.SerializableTypeHandlerCallback"/> <typeHandler javaType="java.io.Serializable" jdbcType="BLOB" callback="org.alfresco.ibatis.SerializableTypeHandlerCallback"/>
<sqlMap resource="alfresco/ibatis/#resource.dialect#/appliedpatch-common-SqlMap.xml"/>
<sqlMap resource="alfresco/ibatis/#resource.dialect#/locks-common-SqlMap.xml"/> <sqlMap resource="alfresco/ibatis/#resource.dialect#/locks-common-SqlMap.xml"/>
<sqlMap resource="alfresco/ibatis/#resource.dialect#/locks-insert-SqlMap.xml"/> <sqlMap resource="alfresco/ibatis/#resource.dialect#/locks-insert-SqlMap.xml"/>
<sqlMap resource="alfresco/ibatis/#resource.dialect#/content-common-SqlMap.xml"/> <sqlMap resource="alfresco/ibatis/#resource.dialect#/content-common-SqlMap.xml"/>

View File

@@ -1,79 +1,80 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<!-- <!--
Beans common to iBatis infrastructure Beans common to iBatis infrastructure
--> -->
<beans> <beans>
<!-- Hierarchical Resource Loader --> <!-- Hierarchical Resource Loader -->
<bean id="dialectResourceLoader" class="org.alfresco.util.resource.HierarchicalResourceLoader"> <bean id="dialectResourceLoader" class="org.alfresco.util.resource.HierarchicalResourceLoader">
<property name="dialectBaseClass"> <property name="dialectBaseClass">
<value>org.hibernate.dialect.Dialect</value> <value>org.hibernate.dialect.Dialect</value>
</property> </property>
<!-- Resolve the (perhaps auto detected) dialect class --> <!-- Resolve the (perhaps auto detected) dialect class -->
<property name="dialectClass"> <property name="dialectClass">
<bean class="org.springframework.beans.factory.config.PropertyPathFactoryBean"> <bean class="org.springframework.beans.factory.config.PropertyPathFactoryBean">
<property name="targetBeanName" value="dialect" /> <property name="targetBeanName" value="dialect" />
<property name="propertyPath" value="class.name" /> <property name="propertyPath" value="class.name" />
</bean> </bean>
</property> </property>
</bean> </bean>
<bean id="activitiesDataSource" class="org.springframework.aop.framework.ProxyFactoryBean"> <bean id="activitiesDataSource" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"> <property name="proxyInterfaces">
<value>javax.sql.DataSource</value> <value>javax.sql.DataSource</value>
</property> </property>
<property name="target"><ref bean="dataSource"/></property> <property name="target"><ref bean="dataSource"/></property>
<property name="interceptorNames"> <property name="interceptorNames">
<list> <list>
<idref local="activitiesDataSource_autoCommit" /> <idref local="activitiesDataSource_autoCommit" />
</list> </list>
</property> </property>
</bean> </bean>
<bean id="activitiesDataSource_autoCommit" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor"> <bean id="activitiesDataSource_autoCommit" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
<property name="advice"> <property name="advice">
<bean class="org.alfresco.util.AutoCommitInterceptor" /> <bean class="org.alfresco.util.AutoCommitInterceptor" />
</property> </property>
<property name="mappedName"> <property name="mappedName">
<value>getConnection</value> <value>getConnection</value>
</property> </property>
</bean> </bean>
<!-- iBatis config for Activities domain --> <!-- iBatis config for Activities domain -->
<bean id="activitiesSqlMapClient" class="org.alfresco.ibatis.HierarchicalSqlMapClientFactoryBean"> <bean id="activitiesSqlMapClient" class="org.alfresco.ibatis.HierarchicalSqlMapClientFactoryBean">
<property name="dataSource" ref="activitiesDataSource"/> <property name="dataSource" ref="activitiesDataSource"/>
<property name="resourceLoader" ref="dialectResourceLoader" /> <property name="resourceLoader" ref="dialectResourceLoader" />
<property name="configLocation"> <property name="configLocation">
<value>classpath:alfresco/ibatis/activities-SqlMapConfig.xml</value> <value>classpath:alfresco/ibatis/activities-SqlMapConfig.xml</value>
</property> </property>
</bean> </bean>
<!-- iBatis config for Alfresco (using common datasource) --> <!-- iBatis config for Alfresco (using common datasource) -->
<bean id="alfrescoSqlMapClient" class="org.alfresco.ibatis.HierarchicalSqlMapClientFactoryBean"> <bean id="alfrescoSqlMapClient" class="org.alfresco.ibatis.HierarchicalSqlMapClientFactoryBean">
<property name="dataSource" ref="dataSource"/> <property name="dataSource" ref="dataSource"/>
<property name="resourceLoader" ref="dialectResourceLoader" /> <property name="resourceLoader" ref="dialectResourceLoader" />
<property name="configLocation"> <property name="configLocation">
<value>classpath:alfresco/ibatis/alfresco-SqlMapConfig.xml</value> <value>classpath:alfresco/ibatis/alfresco-SqlMapConfig.xml</value>
</property> </property>
</bean> </bean>
<bean id="locksSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate"> <bean id="repoSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient" ref="alfrescoSqlMapClient"/> <property name="sqlMapClient" ref="alfrescoSqlMapClient"/>
</bean> </bean>
<bean id="contentSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate"> <bean id="locksSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient" ref="alfrescoSqlMapClient"/> <property name="sqlMapClient" ref="alfrescoSqlMapClient"/>
</bean> </bean>
<bean id="propertyValueSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate"> <bean id="contentSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient" ref="alfrescoSqlMapClient"/> <property name="sqlMapClient" ref="alfrescoSqlMapClient"/>
</bean> </bean>
<bean id="propertyValueSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<bean id="auditSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate"> <property name="sqlMapClient" ref="alfrescoSqlMapClient"/>
<property name="sqlMapClient" ref="alfrescoSqlMapClient"/> </bean>
</bean> <bean id="auditSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient" ref="alfrescoSqlMapClient"/>
<bean id="avmSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate"> </bean>
<property name="sqlMapClient" ref="alfrescoSqlMapClient"/> <bean id="avmSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
</bean> <property name="sqlMapClient" ref="alfrescoSqlMapClient"/>
</bean>
</beans>
</beans>

View File

@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="alfresco.appliedpatch">
<!-- -->
<!-- Type Defs -->
<!-- -->
<typeAlias alias="AppliedPatch" type="org.alfresco.repo.domain.patch.AppliedPatchEntity"/>
<!-- -->
<!-- Result Maps -->
<!-- -->
<resultMap id="result_AppliedPatch" class="AppliedPatch">
<result property="id" column="id" jdbcType="VARCHAR" javaType="string"/>
<result property="description" column="description" jdbcType="VARCHAR" javaType="string"/>
<result property="fixesFromSchema" column="fixes_from_schema" jdbcType="INT" javaType="int" />
<result property="fixesToSchema" column="fixes_to_schema" jdbcType="INT" javaType="int" />
<result property="targetSchema" column="target_schema" jdbcType="INT" javaType="int" />
<result property="appliedToSchema" column="applied_to_schema" jdbcType="INT" javaType="int" />
<result property="appliedOnDate" column="applied_on_date" jdbcType="DATETIME" javaType="date" />
<result property="appliedToServer" column="applied_to_server" jdbcType="VARCHAR" javaType="string"/>
<result property="wasExecuted" column="was_executed" jdbcType="BOOLEAN" javaType="boolean"/>
<result property="succeeded" column="succeeded" jdbcType="BOOLEAN" javaType="boolean"/>
<result property="report" column="report" jdbcType="VARCHAR" javaType="string"/>
</resultMap>
<!-- -->
<!-- SQL Snippets -->
<!-- -->
<!--
<sql id="insert_LockResource_AutoIncrement">
insert into alf_lock_resource (version, qname_ns_id, qname_localname)
values (#version#, #qnameNamespaceId#, #qnameLocalName#)
</sql>
<sql id="insert_Lock_AutoIncrement">
insert into alf_lock (version, shared_resource_id, excl_resource_id, lock_token, start_time, expiry_time)
values (#version#, #sharedResourceId#, #exclusiveResourceId#, #lockToken#, #startTime#, #expiryTime#)
</sql>
-->
<!-- -->
<!-- Inserts -->
<!-- -->
<insert id="insert_AppliedPatch" parameterClass="AppliedPatch">
insert into alf_applied_patch
(
id, description,
fixes_from_schema, fixes_to_schema, target_schema,
applied_to_schema, applied_on_date, applied_to_server,
was_executed, succeeded, report
)
values
(
#id#, #description#,
#fixesFromSchema#, #fixesToSchema#, #targetSchema#,
#appliedToSchema#, #appliedOnDate#, #appliedToServer#,
#wasExecuted#, #succeeded#, #report#
)
</insert>
<!-- -->
<!-- Updates -->
<!-- -->
<insert id="update_AppliedPatch" parameterClass="AppliedPatch">
update alf_applied_patch
set
description = #description#,
fixes_from_schema = #fixesFromSchema#,
fixes_to_schema = #fixesToSchema#,
target_schema = #targetSchema#,
applied_to_schema = #appliedToSchema#,
applied_on_date = #appliedOnDate#,
applied_to_server = #appliedToServer#,
was_executed = #wasExecuted#,
succeeded = #succeeded#,
report = #report#
where
id = #id#
</insert>
<!-- -->
<!-- Statements -->
<!-- -->
<select id="select_AppliedPatchById" parameterClass="AppliedPatch" resultMap="result_AppliedPatch">
select
id, description,
fixes_from_schema, fixes_to_schema, target_schema,
applied_to_schema, applied_on_date, applied_to_server,
was_executed, succeeded, report
from
alf_applied_patch
where
id = #id#
</select>
<select id="select_AllAppliedPatches" resultMap="result_AppliedPatch">
select
id, description,
fixes_from_schema, fixes_to_schema, target_schema,
applied_to_schema, applied_on_date, applied_to_server,
was_executed, succeeded, report
from
alf_applied_patch
order by
target_schema
</select>
</sqlMap>

View File

@@ -176,8 +176,8 @@
<property name="nodeService"> <property name="nodeService">
<ref bean="nodeService" /> <ref bean="nodeService" />
</property> </property>
<property name="patchDao"> <property name="appliedPatchDAO">
<ref bean="patchDaoComponent" /> <ref bean="appliedPatchDAO" />
</property> </property>
<property name="versionCounterService"> <property name="versionCounterService">
<ref bean="versionCounterService" /> <ref bean="versionCounterService" />

View File

@@ -28,12 +28,6 @@
</property> </property>
</bean> </bean>
<bean id="patchDaoComponent" class="org.alfresco.repo.admin.patch.hibernate.HibernatePatchDaoServiceImpl" >
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="patchComponent" class="org.alfresco.repo.admin.patch.PatchServiceImpl" > <bean id="patchComponent" class="org.alfresco.repo.admin.patch.PatchServiceImpl" >
<property name="descriptorService"> <property name="descriptorService">
<ref bean="descriptorComponent" /> <ref bean="descriptorComponent" />
@@ -44,8 +38,8 @@
<property name="ruleService"> <property name="ruleService">
<ref bean="ruleService" /> <ref bean="ruleService" />
</property> </property>
<property name="patchDaoService"> <property name="appliedPatchDAO">
<ref bean="patchDaoComponent" /> <ref bean="appliedPatchDAO" />
</property> </property>
</bean> </bean>

View File

@@ -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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -22,59 +22,55 @@
* the FLOSS exception, and it is also available here: * the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" * http://www.alfresco.com/legal/licensing"
*/ */
package org.alfresco.repo.domain.hibernate; package org.alfresco.repo.admin.patch;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
import org.alfresco.repo.domain.AppliedPatch;
/** /**
* Hibernate-specific implementation of the persistent object. * Applied patch bean
* *
* @author Derek Hulley * @author Derek Hulley
* @since 3.3
*/ */
public class AppliedPatchImpl implements AppliedPatch, Serializable public class AppliedPatch
{ {
private static final long serialVersionUID = 2694230422651768785L;
private String id; private String id;
private String description; private String description;
private int fixesFromSchema; private int fixesFromSchema;
private int fixesToSchema; private int fixesToSchema;
private int targetSchema; private int targetSchema;
private int appliedToSchema; private int appliedToSchema;
private String appliedToServer; private String appliedToServer;
private Date appliedOnDate; private Date appliedOnDate;
private boolean wasExecuted; private boolean wasExecuted;
private boolean succeeded; private boolean succeeded;
private String report; private String report;
public AppliedPatchImpl()
{
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder(256);
sb.append("AppliedPatch")
.append("[ id=").append(id)
.append(", description=").append(description)
.append(", fixesFromSchema=").append(fixesFromSchema)
.append(", fixesToSchema=").append(fixesToSchema)
.append(", targetSchema=").append(targetSchema)
.append(", appliedToSchema=").append(appliedToSchema)
.append(", appliedToServer=").append(appliedToServer)
.append(", appliedOnDate=").append(appliedOnDate)
.append(", wasExecuted=").append(wasExecuted)
.append(", succeeded=").append(succeeded)
.append(", report=").append(report)
.append("]");
return sb.toString();
}
/**
* Default constructor
*/
public AppliedPatch()
{
}
/**
* Construct an instance from another patch info-provider
*/
public AppliedPatch(AppliedPatch appliedPatch)
{
this.id = appliedPatch.getId();
this.description = appliedPatch.getDescription();
this.fixesFromSchema = appliedPatch.getFixesFromSchema();
this.fixesToSchema = appliedPatch.getFixesToSchema();
this.targetSchema = appliedPatch.getTargetSchema();
this.appliedToSchema = appliedPatch.getAppliedToSchema();
this.appliedToServer = appliedPatch.getAppliedToServer();
this.appliedOnDate = appliedPatch.getAppliedOnDate();
this.wasExecuted = appliedPatch.getWasExecuted();
this.succeeded = appliedPatch.getSucceeded();
this.report = appliedPatch.getReport();
}
public String getId() public String getId()
{ {
return id; return id;
@@ -90,60 +86,54 @@ public class AppliedPatchImpl implements AppliedPatch, Serializable
} }
public void setDescription(String description) public void setDescription(String description)
{ {
if (description != null && description.length() > 1024)
{
// truncate as necessary
description = (description.substring(0, 1020) + "...");
}
this.description = description; this.description = description;
} }
public int getFixesFromSchema() public int getFixesFromSchema()
{ {
return fixesFromSchema; return fixesFromSchema;
} }
public void setFixesFromSchema(int version) public void setFixesFromSchema(int fixesFromSchema)
{ {
this.fixesFromSchema = version; this.fixesFromSchema = fixesFromSchema;
} }
public int getFixesToSchema() public int getFixesToSchema()
{ {
return fixesToSchema; return fixesToSchema;
} }
public void setFixesToSchema(int version) public void setFixesToSchema(int fixesToSchema)
{ {
this.fixesToSchema = version; this.fixesToSchema = fixesToSchema;
} }
public int getTargetSchema() public int getTargetSchema()
{ {
return targetSchema; return targetSchema;
} }
public void setTargetSchema(int currentSchema) public void setTargetSchema(int targetSchema)
{ {
this.targetSchema = currentSchema; this.targetSchema = targetSchema;
} }
public int getAppliedToSchema() public int getAppliedToSchema()
{ {
return appliedToSchema; return appliedToSchema;
} }
public void setAppliedToSchema(int version) public void setAppliedToSchema(int appliedToSchema)
{ {
this.appliedToSchema = version; this.appliedToSchema = appliedToSchema;
} }
public String getAppliedToServer() public String getAppliedToServer()
{ {
return appliedToServer; return appliedToServer;
} }
public void setAppliedToServer(String appliedToServer) public void setAppliedToServer(String appliedToServer)
{ {
this.appliedToServer = appliedToServer; this.appliedToServer = appliedToServer;
} }
public Date getAppliedOnDate() public Date getAppliedOnDate()
{ {
return appliedOnDate; return appliedOnDate;
@@ -170,18 +160,13 @@ public class AppliedPatchImpl implements AppliedPatch, Serializable
{ {
this.succeeded = succeeded; this.succeeded = succeeded;
} }
public String getReport() public String getReport()
{ {
return report; return report;
} }
public void setReport(String report) public void setReport(String report)
{ {
if (report != null && report.length() > 1024)
{
// truncate as necessary
report = (report.substring(0, 1020) + "...");
}
this.report = report; this.report = report;
} }
} }

View File

@@ -90,7 +90,7 @@ public class PatchExecuter extends AbstractLifecycleBean
Date after = new Date(System .currentTimeMillis() + 20000L); // 20 seconds ahead Date after = new Date(System .currentTimeMillis() + 20000L); // 20 seconds ahead
// get all the patches executed in the time // get all the patches executed in the time
List<PatchInfo> appliedPatches = patchService.getPatches(before, after); List<AppliedPatch> appliedPatches = patchService.getPatches(before, after);
// don't report anything if nothing was done // don't report anything if nothing was done
if (appliedPatches.size() == 0) if (appliedPatches.size() == 0)
@@ -101,7 +101,7 @@ public class PatchExecuter extends AbstractLifecycleBean
{ {
boolean succeeded = true; boolean succeeded = true;
// list all patches applied, including failures // list all patches applied, including failures
for (PatchInfo patchInfo : appliedPatches) for (AppliedPatch patchInfo : appliedPatches)
{ {
if (!patchInfo.getWasExecuted()) if (!patchInfo.getWasExecuted())
{ {

View File

@@ -27,8 +27,6 @@ package org.alfresco.repo.admin.patch;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
/** /**
* Manages patches applied against the repository. * Manages patches applied against the repository.
* <p> * <p>
@@ -73,5 +71,5 @@ public interface PatchService
* the end date of the search, or null to g * the end date of the search, or null to g
* @return Returns all applied patches (successful or not) * @return Returns all applied patches (successful or not)
*/ */
public List<PatchInfo> getPatches(Date fromDate, Date toDate); public List<AppliedPatch> getPatches(Date fromDate, Date toDate);
} }

View File

@@ -32,8 +32,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.extensions.surf.util.I18NUtil; import org.alfresco.repo.domain.patch.AppliedPatchDAO;
import org.alfresco.repo.domain.AppliedPatch;
import org.alfresco.repo.transaction.TransactionServiceImpl; import org.alfresco.repo.transaction.TransactionServiceImpl;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.admin.PatchException; 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.alfresco.service.descriptor.DescriptorService;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; 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 DescriptorService descriptorService;
private TransactionServiceImpl transactionService; private TransactionServiceImpl transactionService;
private RuleService ruleService; private RuleService ruleService;
private PatchDaoService patchDaoService; private AppliedPatchDAO appliedPatchDAO;
private List<Patch> patches; private List<Patch> patches;
public PatchServiceImpl() public PatchServiceImpl()
@@ -86,9 +86,9 @@ public class PatchServiceImpl implements PatchService
this.transactionService = transactionService; this.transactionService = transactionService;
} }
public void setPatchDaoService(PatchDaoService patchDaoService) public void setAppliedPatchDAO(AppliedPatchDAO appliedPatchDAO)
{ {
this.patchDaoService = patchDaoService; this.appliedPatchDAO = appliedPatchDAO;
} }
public void setRuleService(RuleService ruleService) 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) // construct a list of executed patches by ID (also check the date)
Map<String, AppliedPatch> appliedPatchesById = new HashMap<String, AppliedPatch>(23); Map<String, AppliedPatch> appliedPatchesById = new HashMap<String, AppliedPatch>(23);
List<AppliedPatch> appliedPatches = patchDaoService.getAppliedPatches(); List<AppliedPatch> appliedPatches = appliedPatchDAO.getAppliedPatches();
for (final AppliedPatch appliedPatch : appliedPatches) for (final AppliedPatch appliedPatch : appliedPatches)
{ {
appliedPatchesById.put(appliedPatch.getId(), appliedPatch); appliedPatchesById.put(appliedPatch.getId(), appliedPatch);
@@ -153,7 +153,8 @@ public class PatchServiceImpl implements PatchService
public Date execute() throws Throwable public Date execute() throws Throwable
{ {
Date now = new Date(); Date now = new Date();
patchDaoService.setAppliedOnDate(appliedPatch.getId(), now); appliedPatch.setAppliedOnDate(now);
appliedPatchDAO.updateAppliedPatch(appliedPatch);
return now; return now;
} }
}; };
@@ -255,7 +256,7 @@ public class PatchServiceImpl implements PatchService
" Patch: " + patch); " Patch: " + patch);
} }
// get the patch from the DAO // 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 // We bypass the patch if it was executed successfully
if (appliedPatch != null && !forcePatch) if (appliedPatch != null && !forcePatch)
{ {
@@ -316,9 +317,17 @@ public class PatchServiceImpl implements PatchService
String server = (serverDescriptor.getVersion() + " - " + serverDescriptor.getEdition()); String server = (serverDescriptor.getVersion() + " - " + serverDescriptor.getEdition());
// create or update the record of execution // create or update the record of execution
boolean create = true;
if (appliedPatch == null) 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 // fill in the record's details
String patchDescription = I18NUtil.getMessage(patch.getDescription()); 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.setSucceeded(success); // whether or not the patch succeeded
appliedPatch.setWasExecuted(applies); // whether or not the patch was executed appliedPatch.setWasExecuted(applies); // whether or not the patch was executed
appliedPatch.setReport(report); // additional, human-readable, status appliedPatch.setReport(report); // additional, human-readable, status
// Update or create the entry
if (create)
{
appliedPatchDAO.createAppliedPatch(appliedPatch);
}
else
{
appliedPatchDAO.updateAppliedPatch(appliedPatch);
}
// done // done
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
@@ -359,7 +377,7 @@ public class PatchServiceImpl implements PatchService
for (Patch alternative : alternatives) for (Patch alternative : alternatives)
{ {
// If the patch was executed, then this one was effectively executed // 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()) if (appliedAlternative != null && appliedAlternative.getSucceeded())
{ {
return alternative.getId(); return alternative.getId();
@@ -392,7 +410,7 @@ public class PatchServiceImpl implements PatchService
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<PatchInfo> getPatches(Date fromDate, Date toDate) public List<AppliedPatch> getPatches(Date fromDate, Date toDate)
{ {
if (fromDate == null) if (fromDate == null)
{ {
@@ -402,14 +420,9 @@ public class PatchServiceImpl implements PatchService
{ {
toDate = INFINITE_DATE; toDate = INFINITE_DATE;
} }
List<? extends PatchInfo> appliedPatches = patchDaoService.getAppliedPatches(fromDate, toDate); List<? extends AppliedPatch> appliedPatches = appliedPatchDAO.getAppliedPatches(fromDate, toDate);
// disconnect each of these
for (PatchInfo appliedPatch : appliedPatches)
{
patchDaoService.detach((AppliedPatch)appliedPatch);
}
// done // done
return (List<PatchInfo>) appliedPatches; return (List<AppliedPatch>) appliedPatches;
} }
/** /**

View File

@@ -1,198 +1,188 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2007 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 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 * 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 * the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's * and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing * FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here: * the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" * http://www.alfresco.com/legal/licensing"
*/ */
package org.alfresco.repo.admin.patch; package org.alfresco.repo.admin.patch;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.domain.AppliedPatch; import org.alfresco.repo.security.authentication.AuthenticationContext;
import org.alfresco.repo.security.authentication.AuthenticationContext; import org.alfresco.service.cmr.admin.PatchException;
import org.alfresco.service.cmr.admin.PatchException; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.transaction.TransactionService;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.ApplicationContextHelper; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContext;
/**
/** * @see org.alfresco.repo.admin.patch.Patch
* @see org.alfresco.repo.admin.patch.Patch * @see org.alfresco.repo.admin.patch.AbstractPatch
* @see org.alfresco.repo.admin.patch.AbstractPatch * @see org.alfresco.repo.admin.patch.PatchService
* @see org.alfresco.repo.admin.patch.PatchService *
* * @author Derek Hulley
* @author Derek Hulley */
*/ public class PatchTest extends TestCase
public class PatchTest extends TestCase {
{ private static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
private static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
private TransactionService transactionService;
private TransactionService transactionService; private NamespaceService namespaceService;
private NamespaceService namespaceService; private NodeService nodeService;
private NodeService nodeService; private SearchService searchService;
private SearchService searchService; private AuthenticationContext authenticationContext;
private AuthenticationContext authenticationContext; private PatchService patchService;
private PatchService patchService;
private PatchDaoService patchDaoComponent; public PatchTest(String name)
{
public PatchTest(String name) super(name);
{ }
super(name);
} public void setUp() throws Exception
{
public void setUp() throws Exception transactionService = (TransactionService) ctx.getBean("transactionComponent");
{ namespaceService = (NamespaceService) ctx.getBean("namespaceService");
transactionService = (TransactionService) ctx.getBean("transactionComponent"); nodeService = (NodeService) ctx.getBean("nodeService");
namespaceService = (NamespaceService) ctx.getBean("namespaceService"); searchService = (SearchService) ctx.getBean("searchService");
nodeService = (NodeService) ctx.getBean("nodeService"); authenticationContext = (AuthenticationContext) ctx.getBean("authenticationContext");
searchService = (SearchService) ctx.getBean("searchService");
authenticationContext = (AuthenticationContext) ctx.getBean("authenticationContext"); patchService = (PatchService) ctx.getBean("PatchService");
patchService = (PatchService) ctx.getBean("PatchService"); // get the patches to play with
patchDaoComponent = (PatchDaoService) ctx.getBean("patchDaoComponent"); patchService.registerPatch((Patch)ctx.getBean("patch.sample.02"));
patchService.registerPatch((Patch)ctx.getBean("patch.sample.01"));
// 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);
public void testSetup() throws Exception assertNotNull(patchService);
{ }
assertNotNull(transactionService);
assertNotNull(patchService); private SamplePatch constructSamplePatch(boolean mustFail)
assertNotNull(patchDaoComponent); {
} SamplePatch patch = new SamplePatch(mustFail, transactionService);
patch.setNamespaceService(namespaceService);
private SamplePatch constructSamplePatch(boolean mustFail) patch.setNodeService(nodeService);
{ patch.setSearchService(searchService);
SamplePatch patch = new SamplePatch(mustFail, transactionService); patch.setAuthenticationContext(authenticationContext);
patch.setNamespaceService(namespaceService); // done
patch.setNodeService(nodeService); return patch;
patch.setSearchService(searchService); }
patch.setAuthenticationContext(authenticationContext);
// done public void testSimplePatchSuccess() throws Exception
return patch; {
} Patch patch = constructSamplePatch(false);
String report = patch.apply();
public void testSimplePatchSuccess() throws Exception // check that the report was generated
{ assertEquals("Patch report incorrect", SamplePatch.MSG_SUCCESS, report);
Patch patch = constructSamplePatch(false); }
String report = patch.apply();
// check that the report was generated public void testPatchReapplication()
assertEquals("Patch report incorrect", SamplePatch.MSG_SUCCESS, report); {
} // successfully apply a patch
Patch patch = constructSamplePatch(false);
public void testPatchReapplication() patch.apply();
{ // check that the patch cannot be reapplied
// successfully apply a patch try
Patch patch = constructSamplePatch(false); {
patch.apply(); patch.apply();
// check that the patch cannot be reapplied fail("AbstractPatch failed to prevent reapplication");
try }
{ catch (AlfrescoRuntimeException e)
patch.apply(); {
fail("AbstractPatch failed to prevent reapplication"); // expected
} }
catch (AlfrescoRuntimeException e)
{ // apply an unsuccessful patch
// expected patch = constructSamplePatch(true);
} try
{
// apply an unsuccessful patch patch.apply();
patch = constructSamplePatch(true); fail("Failed patch didn't throw PatchException");
try }
{ catch (PatchException e)
patch.apply(); {
fail("Failed patch didn't throw PatchException"); // expected
} }
catch (PatchException e) // repeat
{ try
// expected {
} patch.apply();
// repeat fail("Reapplication of failed patch didn't throw PatchException");
try }
{ catch (PatchException e)
patch.apply(); {
fail("Reapplication of failed patch didn't throw PatchException"); // expected
} }
catch (PatchException e) }
{
// expected public void testApplyOutstandingPatches() throws Exception
} {
} // apply outstanding patches
boolean success = patchService.applyOutstandingPatches();
public void testApplyOutstandingPatches() throws Exception assertTrue(success);
{ // get applied patches
// apply outstanding patches List<AppliedPatch> appliedPatches = patchService.getPatches(null, null);
boolean success = patchService.applyOutstandingPatches(); // check that the patch application was recorded
assertTrue(success); boolean found01 = false;
// get applied patches boolean found02 = false;
List<AppliedPatch> appliedPatches = patchDaoComponent.getAppliedPatches(); for (AppliedPatch appliedPatch : appliedPatches)
// check that the patch application was recorded {
boolean found01 = false; if (appliedPatch.getId().equals("Sample01"))
boolean found02 = false; {
for (AppliedPatch appliedPatch : appliedPatches) found01 = true;
{ assertTrue("Patch info didn't indicate success: " + appliedPatch, appliedPatch.getSucceeded());
if (appliedPatch.getId().equals("Sample01")) }
{ else if (appliedPatch.getId().equals("Sample02"))
found01 = true; {
assertTrue("Patch info didn't indicate success: " + appliedPatch, appliedPatch.getSucceeded()); found02 = true;
} assertTrue("Patch info didn't indicate success: " + appliedPatch, appliedPatch.getSucceeded());
else if (appliedPatch.getId().equals("Sample02")) }
{ }
found02 = true; assertTrue("Sample 01 not in list of applied patches", found01);
assertTrue("Patch info didn't indicate success: " + appliedPatch, appliedPatch.getSucceeded()); assertTrue("Sample 02 not in list of applied patches", found02);
} }
}
assertTrue("Sample 01 not in list of applied patches", found01); public void testGetPatchesByDate() throws Exception
assertTrue("Sample 02 not in list of applied patches", found02); {
} // ensure that there are some applied patches
testApplyOutstandingPatches();
public void testGetPatchesByDate() throws Exception // get the number of applied patches
{ List<AppliedPatch> appliedPatches = patchService.getPatches(null, null);
// ensure that there are some applied patches assertTrue("Expected at least 2 applied patches", appliedPatches.size() >= 2);
testApplyOutstandingPatches();
// get the number of applied patches // now requery using null dates
List<AppliedPatch> appliedPatches = patchDaoComponent.getAppliedPatches(); List<AppliedPatch> appliedPatchesAllDates = patchService.getPatches(null, null);
assertTrue("Expected at least 2 applied patches", appliedPatches.size() >= 2); assertEquals("Applied patches by all dates doesn't match all applied patches",
appliedPatches.size(), appliedPatchesAllDates.size());
// now requery using null dates
List<PatchInfo> appliedPatchesAllDates = patchService.getPatches(null, null); // perform another query with dates that should return no results
assertEquals("Applied patches by all dates doesn't match all applied patches", List<AppliedPatch> appliedPatchesFutureDates = patchService.getPatches(new Date(), new Date());
appliedPatches.size(), appliedPatchesAllDates.size()); assertEquals("Query returned results for dates when no patches should exist", 0, appliedPatchesFutureDates.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<PatchInfo> appliedPatchesFutureDates = patchService.getPatches(new Date(), new Date());
assertEquals("Query returned results for dates when no patches should exist", 0, appliedPatchesFutureDates.size());
}
}

View File

@@ -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<AppliedPatch> getAppliedPatches()
{
HibernateCallback callback = new HibernateCallback()
{
public Object doInHibernate(Session session)
{
Query query = session.getNamedQuery(HibernatePatchDaoServiceImpl.QUERY_GET_ALL_APPLIED_PATCHES);
return query.list();
}
};
List<AppliedPatch> queryResults = (List) getHibernateTemplate().execute(callback);
// done
return queryResults;
}
/**
* @see #QUERY_GET_APPLIED_PATCHES_BY_DATE
*/
@SuppressWarnings("unchecked")
public List<AppliedPatch> 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<AppliedPatch> queryResults = (List) getHibernateTemplate().execute(callback);
// eliminate results that are out of range
Iterator<AppliedPatch> 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);
}
}

View File

@@ -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);
}

View File

@@ -33,6 +33,7 @@ import org.alfresco.repo.domain.encoding.EncodingDAOTest;
import org.alfresco.repo.domain.hibernate.HibernateSessionHelperTest; import org.alfresco.repo.domain.hibernate.HibernateSessionHelperTest;
import org.alfresco.repo.domain.locks.LockDAOTest; import org.alfresco.repo.domain.locks.LockDAOTest;
import org.alfresco.repo.domain.mimetype.MimetypeDAOTest; import org.alfresco.repo.domain.mimetype.MimetypeDAOTest;
import org.alfresco.repo.domain.patch.AppliedPatchDAOTest;
/** /**
* Suite for domain-related tests. * Suite for domain-related tests.
@@ -55,6 +56,7 @@ public class DomainTestSuite extends TestSuite
suite.addTestSuite(QNameDAOTest.class); suite.addTestSuite(QNameDAOTest.class);
suite.addTestSuite(PropertyValueTest.class); suite.addTestSuite(PropertyValueTest.class);
suite.addTestSuite(AuditDAOTest.class); suite.addTestSuite(AuditDAOTest.class);
suite.addTestSuite(AppliedPatchDAOTest.class);
return suite; return suite;
} }

View File

@@ -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 <b>alf_applied_patch</b>.
*
* @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<AppliedPatch> getAppliedPatches()
{
List<AppliedPatchEntity> entities = getAppliedPatchEntities();
List<AppliedPatch> results = new ArrayList<AppliedPatch>();
results.addAll(entities);
return results;
}
public List<AppliedPatch> getAppliedPatches(Date from, Date to)
{
// Manual filter (no performance required)
List<AppliedPatch> results = getAppliedPatches();
Iterator<AppliedPatch> 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<AppliedPatchEntity> getAppliedPatchEntities();
}

View File

@@ -22,48 +22,38 @@
* the FLOSS exception, and it is also available here: * the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" * 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.Date;
import java.util.List; 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 <b>alf_applied_patch</b>.
* *
* @since 1.2 * @since 3.3
* @author Derek Hulley * @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 * Creates and saves a new instance of the patch.
* properties set - only the ID.
* *
* @param id the unique key * @param patchInfo the patch ID and details
* @return Returns a new instance that can be manipulated
*/ */
public AppliedPatch newAppliedPatch(String id); public void createAppliedPatch(AppliedPatch appliedPatch);
public void updateAppliedPatch(AppliedPatch appliedPatch);
/** /**
* Retrieve an existing patch * Retrieve an existing patch
* *
* @param id the patch unique ID * @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 <tt>null</tt> if one has not been persisted
*/ */
public AppliedPatch getAppliedPatch(String id); 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 * Get a list of all applied patches
* *

View File

@@ -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<Void> callback = new RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
appliedPatchDAO.createAppliedPatch(appliedPatch);
return null;
}
};
txnHelper.doInTransaction(callback);
return appliedPatch;
}
private AppliedPatch get(final String id) throws Exception
{
RetryingTransactionCallback<AppliedPatch> callback = new RetryingTransactionCallback<AppliedPatch>()
{
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<Void> callback = new RetryingTransactionCallback<Void>()
{
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<Long, String> lowercasePair = get(encoding.toLowerCase(), true, true);
// // Check that the same pair is retrievable using uppercase
// Pair<Long, String> uppercasePair = get(encoding.toUpperCase(), true, true);
// assertNotNull(uppercasePair);
// assertEquals(
// "Upper and lowercase encoding instance IDs were not the same",
// lowercasePair.getFirst(), uppercasePair.getFirst());
// }
}

View File

@@ -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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -22,36 +22,25 @@
* the FLOSS exception, and it is also available here: * the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" * 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 <b>alf_applied_patch</b> persistence.
* *
* @author Derek Hulley * @author Derek Hulley
* @since 3.3
*/ */
public interface PatchInfo public class AppliedPatchEntity extends AppliedPatch
{ {
public String getId(); public AppliedPatchEntity()
{
public String getDescription(); super();
}
public int getFixesFromSchema(); public AppliedPatchEntity(AppliedPatch appliedPatch)
{
public int getFixesToSchema(); super(appliedPatch);
}
public int getTargetSchema();
public int getAppliedToSchema();
public String getAppliedToServer();
public Date getAppliedOnDate();
public boolean getWasExecuted();
public boolean getSucceeded();
public String getReport();
} }

View File

@@ -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<AppliedPatchEntity> getAppliedPatchEntities()
{
return (List<AppliedPatchEntity>) 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;
// }
}

View File

@@ -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_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 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 @Override
protected Long getAVMNodeEntitiesCountWhereNewInStore() 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") @SuppressWarnings("unchecked")
@Override @Override
protected List<AVMNodeEntity> getAVMNodeEntitiesWithEmptyGUID() protected List<AVMNodeEntity> getAVMNodeEntitiesWithEmptyGUID()
{ {
return (List<AVMNodeEntity>) avmTemplate.queryForList(SELECT_AVM_NODE_ENTITIES_WITH_EMPTY_GUID); return (List<AVMNodeEntity>) template.queryForList(SELECT_AVM_NODE_ENTITIES_WITH_EMPTY_GUID);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
protected List<AVMNodeEntity> getNullVersionLayeredDirectoryNodeEntities() protected List<AVMNodeEntity> getNullVersionLayeredDirectoryNodeEntities()
{ {
return (List<AVMNodeEntity>) avmTemplate.queryForList(SELECT_AVM_LD_NODE_ENTITIES_NULL_VERSION); return (List<AVMNodeEntity>) template.queryForList(SELECT_AVM_LD_NODE_ENTITIES_NULL_VERSION);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
protected List<AVMNodeEntity> getNullVersionLayeredFileNodeEntities() protected List<AVMNodeEntity> getNullVersionLayeredFileNodeEntities()
{ {
return (List<AVMNodeEntity>) avmTemplate.queryForList(SELECT_AVM_LF_NODE_ENTITIES_NULL_VERSION); return (List<AVMNodeEntity>) template.queryForList(SELECT_AVM_LF_NODE_ENTITIES_NULL_VERSION);
} }
} }

View File

@@ -28,8 +28,8 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List; import java.util.List;
import org.alfresco.repo.admin.patch.PatchDaoService; import org.alfresco.repo.admin.patch.AppliedPatch;
import org.alfresco.repo.domain.AppliedPatch; import org.alfresco.repo.domain.patch.AppliedPatchDAO;
import org.alfresco.repo.version.common.counter.VersionCounterService; import org.alfresco.repo.version.common.counter.VersionCounterService;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
@@ -44,7 +44,7 @@ public class SystemExporterImporter
{ {
// dependencies // dependencies
private NodeService nodeService; private NodeService nodeService;
private PatchDaoService patchDao; private AppliedPatchDAO appliedPatchDAO;
private VersionCounterService versionCounterService; private VersionCounterService versionCounterService;
@@ -53,9 +53,9 @@ public class SystemExporterImporter
this.nodeService = nodeService; this.nodeService = nodeService;
} }
public void setPatchDao(PatchDaoService patchDaoService) public void setAppliedPatchDAO(AppliedPatchDAO appliedPatchDAO)
{ {
this.patchDao = patchDaoService; this.appliedPatchDAO = appliedPatchDAO;
} }
public void setVersionCounterService(VersionCounterService versionCounterService) public void setVersionCounterService(VersionCounterService versionCounterService)
@@ -74,7 +74,7 @@ public class SystemExporterImporter
SystemInfo systemInfo = new SystemInfo(); SystemInfo systemInfo = new SystemInfo();
// capture applied patches // capture applied patches
List<AppliedPatch> patches = patchDao.getAppliedPatches(); List<AppliedPatch> patches = appliedPatchDAO.getAppliedPatches();
for (AppliedPatch patch : patches) for (AppliedPatch patch : patches)
{ {
PatchInfo patchInfo = new PatchInfo(); PatchInfo patchInfo = new PatchInfo();
@@ -119,7 +119,8 @@ public class SystemExporterImporter
// apply patch info // apply patch info
for (PatchInfo patchInfo : systemInfo.patches) for (PatchInfo patchInfo : systemInfo.patches)
{ {
AppliedPatch patch = patchDao.newAppliedPatch(patchInfo.id); AppliedPatch patch = new AppliedPatch();
patch.setId(patchInfo.id);
patch.setAppliedOnDate(patchInfo.appliedOnDate); patch.setAppliedOnDate(patchInfo.appliedOnDate);
patch.setAppliedToSchema(patchInfo.appliedToSchema); patch.setAppliedToSchema(patchInfo.appliedToSchema);
patch.setAppliedToServer(patchInfo.appliedToServer); patch.setAppliedToServer(patchInfo.appliedToServer);
@@ -130,6 +131,7 @@ public class SystemExporterImporter
patch.setSucceeded(patchInfo.succeeded); patch.setSucceeded(patchInfo.succeeded);
patch.setTargetSchema(patchInfo.targetSchema); patch.setTargetSchema(patchInfo.targetSchema);
patch.setWasExecuted(patchInfo.wasExecuted); patch.setWasExecuted(patchInfo.wasExecuted);
appliedPatchDAO.createAppliedPatch(patch);
} }
// apply version counters // apply version counters