mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
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:
@@ -68,6 +68,7 @@
|
||||
</property>
|
||||
<property name="preCreateScriptUrls">
|
||||
<list>
|
||||
<value>classpath:alfresco/dbscripts/create/3.3/${db.script.dialect}/AlfrescoCreate-3.3-RepoTables.sql</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="postCreateScriptUrls">
|
||||
|
@@ -15,6 +15,14 @@
|
||||
<property name="sqlMapClient" ref="activitiesSqlMapClient"/>
|
||||
</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">
|
||||
<property name="sqlMapClientTemplate" ref="locksSqlMapClientTemplate"/>
|
||||
<property name="qnameDAO" ref="qnameDAO"/>
|
||||
@@ -71,44 +79,28 @@
|
||||
|
||||
<bean id="newAvmStoreDAO" class="org.alfresco.repo.domain.avm.ibatis.AVMStoreDAOImpl">
|
||||
<property name="sqlMapClientTemplate" ref="avmSqlMapClientTemplate"/>
|
||||
|
||||
<property name="qnameDAO" ref="qnameDAO"/>
|
||||
|
||||
<property name="avmStoreCache" ref="avmStoreCache"/>
|
||||
<property name="avmStorePropertyCache" ref="avmEntityCache"/>
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="newAvmNodeDAO" class="org.alfresco.repo.domain.avm.ibatis.AVMNodeDAOImpl">
|
||||
<property name="sqlMapClientTemplate" ref="avmSqlMapClientTemplate"/>
|
||||
|
||||
<property name="qnameDAO" ref="qnameDAO"/>
|
||||
|
||||
<property name="avmNodeCache" ref="avmNodeCache"/>
|
||||
<property name="avmNodePropertyCache" ref="avmEntityCache"/>
|
||||
<property name="avmNodeAspectsCache" ref="avmNodeAspectsCache"/>
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="newAvmNodeLinksDAO" class="org.alfresco.repo.domain.avm.ibatis.AVMNodeLinksDAOImpl">
|
||||
<property name="sqlMapClientTemplate" ref="avmSqlMapClientTemplate"/>
|
||||
|
||||
<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>
|
||||
|
||||
<!-- Patch -->
|
||||
|
||||
<bean id="patchDAO" class="org.alfresco.repo.domain.patch.ibatis.PatchDAOImpl">
|
||||
<property name="avmSqlMapClientTemplate" ref="avmSqlMapClientTemplate"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
@@ -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;
|
@@ -85,13 +85,6 @@
|
||||
eternal="true"
|
||||
overflowToDisk="false"
|
||||
/>
|
||||
<!-- approx 0.1MB memory required -->
|
||||
<cache
|
||||
name="org.alfresco.repo.domain.hibernate.AppliedPatchImpl"
|
||||
maxElementsInMemory="100"
|
||||
timeToLiveSeconds="300"
|
||||
overflowToDisk="false"
|
||||
/>
|
||||
<!-- Permission related caches -->
|
||||
<!-- approx 1MB memory required -->
|
||||
<cache
|
||||
|
@@ -200,23 +200,6 @@
|
||||
replicateAsynchronously = false"/>
|
||||
</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
|
||||
name="org.alfresco.repo.domain.hibernate.DbAccessControlEntryContextImpl"
|
||||
maxElementsInMemory="1000"
|
||||
|
@@ -61,7 +61,6 @@
|
||||
<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/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/attributes/hibernate/Attributes.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.ServerImpl">${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.DbAccessControlEntryImpl">${cache.strategy}</prop>
|
||||
|
@@ -10,6 +10,7 @@
|
||||
|
||||
<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-insert-SqlMap.xml"/>
|
||||
<sqlMap resource="alfresco/ibatis/#resource.dialect#/content-common-SqlMap.xml"/>
|
||||
|
@@ -58,6 +58,9 @@
|
||||
<value>classpath:alfresco/ibatis/alfresco-SqlMapConfig.xml</value>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="repoSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
|
||||
<property name="sqlMapClient" ref="alfrescoSqlMapClient"/>
|
||||
</bean>
|
||||
<bean id="locksSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
|
||||
<property name="sqlMapClient" ref="alfrescoSqlMapClient"/>
|
||||
</bean>
|
||||
@@ -67,11 +70,9 @@
|
||||
<bean id="propertyValueSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
|
||||
<property name="sqlMapClient" ref="alfrescoSqlMapClient"/>
|
||||
</bean>
|
||||
|
||||
<bean id="auditSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
|
||||
<property name="sqlMapClient" ref="alfrescoSqlMapClient"/>
|
||||
</bean>
|
||||
|
||||
<bean id="avmSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
|
||||
<property name="sqlMapClient" ref="alfrescoSqlMapClient"/>
|
||||
</bean>
|
||||
|
@@ -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>
|
@@ -176,8 +176,8 @@
|
||||
<property name="nodeService">
|
||||
<ref bean="nodeService" />
|
||||
</property>
|
||||
<property name="patchDao">
|
||||
<ref bean="patchDaoComponent" />
|
||||
<property name="appliedPatchDAO">
|
||||
<ref bean="appliedPatchDAO" />
|
||||
</property>
|
||||
<property name="versionCounterService">
|
||||
<ref bean="versionCounterService" />
|
||||
|
@@ -28,12 +28,6 @@
|
||||
</property>
|
||||
</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" >
|
||||
<property name="descriptorService">
|
||||
<ref bean="descriptorComponent" />
|
||||
@@ -44,8 +38,8 @@
|
||||
<property name="ruleService">
|
||||
<ref bean="ruleService" />
|
||||
</property>
|
||||
<property name="patchDaoService">
|
||||
<ref bean="patchDaoComponent" />
|
||||
<property name="appliedPatchDAO">
|
||||
<ref bean="appliedPatchDAO" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
@@ -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,28 +22,23 @@
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* 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 org.alfresco.repo.domain.AppliedPatch;
|
||||
|
||||
/**
|
||||
* Hibernate-specific implementation of the persistent object.
|
||||
* Applied patch bean
|
||||
*
|
||||
* @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 description;
|
||||
private int fixesFromSchema;
|
||||
private int fixesToSchema;
|
||||
private int targetSchema;
|
||||
|
||||
private int appliedToSchema;
|
||||
private String appliedToServer;
|
||||
private Date appliedOnDate;
|
||||
@@ -51,28 +46,29 @@ public class AppliedPatchImpl implements AppliedPatch, Serializable
|
||||
private boolean succeeded;
|
||||
private String report;
|
||||
|
||||
public AppliedPatchImpl()
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public AppliedPatch()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
/**
|
||||
* Construct an instance from another patch info-provider
|
||||
*/
|
||||
public AppliedPatch(AppliedPatch appliedPatch)
|
||||
{
|
||||
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();
|
||||
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()
|
||||
@@ -90,11 +86,6 @@ public class AppliedPatchImpl implements AppliedPatch, Serializable
|
||||
}
|
||||
public void setDescription(String description)
|
||||
{
|
||||
if (description != null && description.length() > 1024)
|
||||
{
|
||||
// truncate as necessary
|
||||
description = (description.substring(0, 1020) + "...");
|
||||
}
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@@ -102,43 +93,42 @@ public class AppliedPatchImpl implements AppliedPatch, Serializable
|
||||
{
|
||||
return fixesFromSchema;
|
||||
}
|
||||
public void setFixesFromSchema(int version)
|
||||
public void setFixesFromSchema(int fixesFromSchema)
|
||||
{
|
||||
this.fixesFromSchema = version;
|
||||
this.fixesFromSchema = fixesFromSchema;
|
||||
}
|
||||
|
||||
public int getFixesToSchema()
|
||||
{
|
||||
return fixesToSchema;
|
||||
}
|
||||
public void setFixesToSchema(int version)
|
||||
public void setFixesToSchema(int fixesToSchema)
|
||||
{
|
||||
this.fixesToSchema = version;
|
||||
this.fixesToSchema = fixesToSchema;
|
||||
}
|
||||
|
||||
public int getTargetSchema()
|
||||
{
|
||||
return targetSchema;
|
||||
}
|
||||
public void setTargetSchema(int currentSchema)
|
||||
public void setTargetSchema(int targetSchema)
|
||||
{
|
||||
this.targetSchema = currentSchema;
|
||||
this.targetSchema = targetSchema;
|
||||
}
|
||||
|
||||
public int getAppliedToSchema()
|
||||
{
|
||||
return appliedToSchema;
|
||||
}
|
||||
public void setAppliedToSchema(int version)
|
||||
public void setAppliedToSchema(int appliedToSchema)
|
||||
{
|
||||
this.appliedToSchema = version;
|
||||
this.appliedToSchema = appliedToSchema;
|
||||
}
|
||||
|
||||
public String getAppliedToServer()
|
||||
{
|
||||
return appliedToServer;
|
||||
}
|
||||
|
||||
public void setAppliedToServer(String appliedToServer)
|
||||
{
|
||||
this.appliedToServer = appliedToServer;
|
||||
@@ -177,11 +167,6 @@ public class AppliedPatchImpl implements AppliedPatch, Serializable
|
||||
}
|
||||
public void setReport(String report)
|
||||
{
|
||||
if (report != null && report.length() > 1024)
|
||||
{
|
||||
// truncate as necessary
|
||||
report = (report.substring(0, 1020) + "...");
|
||||
}
|
||||
this.report = report;
|
||||
}
|
||||
}
|
@@ -90,7 +90,7 @@ public class PatchExecuter extends AbstractLifecycleBean
|
||||
Date after = new Date(System .currentTimeMillis() + 20000L); // 20 seconds ahead
|
||||
|
||||
// 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
|
||||
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())
|
||||
{
|
||||
|
@@ -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.
|
||||
* <p>
|
||||
@@ -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<PatchInfo> getPatches(Date fromDate, Date toDate);
|
||||
public List<AppliedPatch> getPatches(Date fromDate, Date toDate);
|
||||
}
|
||||
|
@@ -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<Patch> 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<String, AppliedPatch> appliedPatchesById = new HashMap<String, AppliedPatch>(23);
|
||||
List<AppliedPatch> appliedPatches = patchDaoService.getAppliedPatches();
|
||||
List<AppliedPatch> 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<PatchInfo> getPatches(Date fromDate, Date toDate)
|
||||
public List<AppliedPatch> 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<PatchInfo>) appliedPatches;
|
||||
return (List<AppliedPatch>) appliedPatches;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -30,7 +30,6 @@ 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;
|
||||
@@ -57,7 +56,6 @@ public class PatchTest extends TestCase
|
||||
private SearchService searchService;
|
||||
private AuthenticationContext authenticationContext;
|
||||
private PatchService patchService;
|
||||
private PatchDaoService patchDaoComponent;
|
||||
|
||||
public PatchTest(String name)
|
||||
{
|
||||
@@ -73,7 +71,6 @@ public class PatchTest extends TestCase
|
||||
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"));
|
||||
@@ -84,7 +81,6 @@ public class PatchTest extends TestCase
|
||||
{
|
||||
assertNotNull(transactionService);
|
||||
assertNotNull(patchService);
|
||||
assertNotNull(patchDaoComponent);
|
||||
}
|
||||
|
||||
private SamplePatch constructSamplePatch(boolean mustFail)
|
||||
@@ -151,7 +147,7 @@ public class PatchTest extends TestCase
|
||||
boolean success = patchService.applyOutstandingPatches();
|
||||
assertTrue(success);
|
||||
// get applied patches
|
||||
List<AppliedPatch> appliedPatches = patchDaoComponent.getAppliedPatches();
|
||||
List<AppliedPatch> appliedPatches = patchService.getPatches(null, null);
|
||||
// check that the patch application was recorded
|
||||
boolean found01 = false;
|
||||
boolean found02 = false;
|
||||
@@ -177,22 +173,16 @@ public class PatchTest extends TestCase
|
||||
// ensure that there are some applied patches
|
||||
testApplyOutstandingPatches();
|
||||
// get the number of applied patches
|
||||
List<AppliedPatch> appliedPatches = patchDaoComponent.getAppliedPatches();
|
||||
List<AppliedPatch> appliedPatches = patchService.getPatches(null, null);
|
||||
assertTrue("Expected at least 2 applied patches", appliedPatches.size() >= 2);
|
||||
|
||||
// now requery using null dates
|
||||
List<PatchInfo> appliedPatchesAllDates = patchService.getPatches(null, null);
|
||||
List<AppliedPatch> 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<PatchInfo> appliedPatchesFutureDates = patchService.getPatches(new Date(), new Date());
|
||||
List<AppliedPatch> appliedPatchesFutureDates = patchService.getPatches(new Date(), new Date());
|
||||
assertEquals("Query returned results for dates when no patches should exist", 0, appliedPatchesFutureDates.size());
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
@@ -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 <b>alf_applied_patch</b>.
|
||||
*
|
||||
* @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 <tt>null</tt> 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
|
||||
*
|
@@ -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());
|
||||
// }
|
||||
}
|
@@ -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 <b>alf_applied_patch</b> persistence.
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 3.3
|
||||
*/
|
||||
public interface PatchInfo
|
||||
public class AppliedPatchEntity extends AppliedPatch
|
||||
{
|
||||
public String getId();
|
||||
public AppliedPatchEntity()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public String getDescription();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@@ -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;
|
||||
// }
|
||||
}
|
@@ -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<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")
|
||||
@Override
|
||||
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")
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -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<AppliedPatch> patches = patchDao.getAppliedPatches();
|
||||
List<AppliedPatch> 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
|
||||
|
Reference in New Issue
Block a user