org.alfresco.repo.admin.patch
Class AbstractPatch

java.lang.Object
  extended by org.alfresco.repo.admin.patch.AbstractPatch
All Implemented Interfaces:
Patch
Direct Known Subclasses:
AbstractPermissionChangePatch, ActionRuleDecouplingPatch, AVMAspectsPatch, AVMGuidPatch, AVMLayeredSnapshotPatch, AVMLockingPatch, AVMPermissionsPatch, AVMPropertiesPatch, AVMWebProjectInheritPermissionsPatch, BaseReindexingPatch, CategoryRootPermissionPatch, ContentFormTypePatch, DeploymentMigrationPatch, DescriptorUpdatePatch, DmPermissionsPatch, EmailTemplatesContentPatch, EmailTemplatesFolderPatch, ForumsIconsPatch, GenericBootstrapPatch, GenericWorkflowPatch, GroupTokenisationPatch, GuestPersonPermissionPatch, GuestPersonPermissionPatch2, GuestUserPatch, InvalidNameEndingPatch, InvalidUserPersonAndGroupPatch, LinkNodeFileExtensionPatch, NodePropertySerializablePatch, RSSTemplatesFolderPatch, SamplePatch, SavedSearchFolderPatch, SchemaUpgradeScriptPatch, ScriptsFolderPatch, SitePermissionRefactorPatch, SiteStorePatch, SpacesRootPermissionPatch, SystemDescriptorContentPatch, SystemWorkflowFolderPatch, TopLevelGroupParentChildAssociationTypePatch, UIFacetsAspectRemovalPatch, UniqueChildNamePatch, UserAndPersonTokenisationPatch, VersionHistoryPerformancePatch, WCMFoldersPatch, WCMPermissionPatch, WCMPostPermissionSnapshotPatch

public abstract class AbstractPatch
extends java.lang.Object
implements Patch

Base implementation of the patch. This class ensures that the patch is thread- and transaction-safe.


Field Summary
protected  AuthenticationComponent authenticationComponent
          support service
static java.lang.String ERR_PROPERTY_NOT_SET
          I18N message when properties not set.
protected  NamespaceService namespaceService
          support service
protected  NodeService nodeService
          support service
protected  SearchService searchService
          support service
protected  TenantDeployerService tenantDeployerService
          support service
protected  TransactionService transactionService
          used to ensure a unique transaction per execution
 
Constructor Summary
AbstractPatch()
           
 
Method Summary
 boolean applies(int version)
          Check if the patch is applicable to a given schema version.
 java.lang.String apply()
          Sets up the transaction and ensures thread-safety.
protected abstract  java.lang.String applyInternal()
          This method does the work.
protected  void checkProperties()
          Check that the schema version properties have been set appropriately.
protected  void checkPropertyNotNull(java.lang.Object value, java.lang.String name)
          Performs a null check on the supplied value.
 java.util.List getDependsOn()
          Get patches that this patch depends on
 java.lang.String getDescription()
           
 int getFixesFromSchema()
           
 int getFixesToSchema()
           
 java.lang.String getId()
           
 int getTargetSchema()
           
 void init()
          This ensures that this bean gets registered with the appropriate service.
protected  void reportProgress(long estimatedTotal, long currentInteration)
          Support to report patch completion and estimated completion time.
 void setApplyToTenants(boolean applyToTenants)
           
 void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
          Set a generally-used service
 void setDependsOn(java.util.List dependsOn)
          Set all the dependencies for this patch.
 void setDescription(java.lang.String description)
           
 void setFixesFromSchema(int version)
          Set the smallest schema number that this patch may be applied to.
 void setFixesToSchema(int version)
          Set the largest schema version number that this patch may be applied to.
 void setId(java.lang.String id)
           
 void setNamespaceService(NamespaceService namespaceService)
          Set a generally-used service
 void setNodeService(NodeService nodeService)
          Set a generally-used service
 void setPatchService(PatchService patchService)
          Set the service that this patch will register with for execution.
 void setSearchService(SearchService searchService)
          Set a generally-used service
 void setTargetSchema(int version)
          Set the schema version that this patch attempts to take the existing schema to.
 void setTenantDeployerService(TenantDeployerService tenantDeployerService)
           
 void setTransactionService(TransactionService transactionService)
          Set the transaction provider so that each execution can be performed within a transaction
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ERR_PROPERTY_NOT_SET

public static final java.lang.String ERR_PROPERTY_NOT_SET
I18N message when properties not set.

See Also:
Constant Field Values

transactionService

protected TransactionService transactionService
used to ensure a unique transaction per execution


namespaceService

protected NamespaceService namespaceService
support service


nodeService

protected NodeService nodeService
support service


searchService

protected SearchService searchService
support service


authenticationComponent

protected AuthenticationComponent authenticationComponent
support service


tenantDeployerService

protected TenantDeployerService tenantDeployerService
support service

Constructor Detail

AbstractPatch

public AbstractPatch()
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setPatchService

public void setPatchService(PatchService patchService)
Set the service that this patch will register with for execution.


setTransactionService

public void setTransactionService(TransactionService transactionService)
Set the transaction provider so that each execution can be performed within a transaction


setNamespaceService

public void setNamespaceService(NamespaceService namespaceService)
Set a generally-used service


setNodeService

public void setNodeService(NodeService nodeService)
Set a generally-used service


setSearchService

public void setSearchService(SearchService searchService)
Set a generally-used service


setAuthenticationComponent

public void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
Set a generally-used service


setTenantDeployerService

public void setTenantDeployerService(TenantDeployerService tenantDeployerService)

init

public void init()
This ensures that this bean gets registered with the appropriate service.


getId

public java.lang.String getId()
Specified by:
getId in interface Patch

setId

public void setId(java.lang.String id)
Parameters:
id - the unique ID of the patch. This dictates the order in which patches are applied.

getFixesFromSchema

public int getFixesFromSchema()
Specified by:
getFixesFromSchema in interface Patch
Returns:
Returns the smallest schema number that this patch may be applied to

setFixesFromSchema

public void setFixesFromSchema(int version)
Set the smallest schema number that this patch may be applied to.

Parameters:
version - a schema number not smaller than 0

getFixesToSchema

public int getFixesToSchema()
Specified by:
getFixesToSchema in interface Patch
Returns:
Returns the largest schema number that this patch may be applied to

setFixesToSchema

public void setFixesToSchema(int version)
Set the largest schema version number that this patch may be applied to.

Parameters:
version - a schema version number not smaller than the from version number.

getTargetSchema

public int getTargetSchema()
Specified by:
getTargetSchema in interface Patch
Returns:
Returns the schema number that this patch attempts to bring the repo up to

setTargetSchema

public void setTargetSchema(int version)
Set the schema version that this patch attempts to take the existing schema to. This is for informational purposes only, acting as an indicator of intention rather than having any specific effect.

Parameters:
version - a schema version number that must be greater than the max fix schema number

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in interface Patch

setDescription

public void setDescription(java.lang.String description)
Parameters:
description - a thorough description of the patch

getDependsOn

public java.util.List getDependsOn()
Description copied from interface: Patch
Get patches that this patch depends on

Specified by:
getDependsOn in interface Patch
Returns:
Returns a list of patches

setDependsOn

public void setDependsOn(java.util.List dependsOn)
Set all the dependencies for this patch. It should not be executed before all the dependencies have been applied.

Parameters:
dependsOn - a list of dependencies

applies

public boolean applies(int version)
Description copied from interface: Patch
Check if the patch is applicable to a given schema version.

Specified by:
applies in interface Patch
Parameters:
version - a schema version number
Returns:
Returns (fixesFromVersion <= version <= fixesToVersion)

checkPropertyNotNull

protected final void checkPropertyNotNull(java.lang.Object value,
                                          java.lang.String name)
Performs a null check on the supplied value.

Parameters:
value - value to check
name - name of the property to report

setApplyToTenants

public void setApplyToTenants(boolean applyToTenants)

checkProperties

protected void checkProperties()
Check that the schema version properties have been set appropriately. Derived classes can override this method to perform their own validation provided that this method is called by the derived class.


apply

public java.lang.String apply()
                       throws PatchException
Sets up the transaction and ensures thread-safety.

Specified by:
apply in interface Patch
Returns:
Returns the patch execution report
Throws:
PatchException - if the patch failed to be applied
See Also:
AbstractPatch.applyInternal()

applyInternal

protected abstract java.lang.String applyInternal()
                                           throws java.lang.Exception
This method does the work. All transactions and thread-safety will be taken care of by this class. Any exception will result in the transaction being rolled back. Integrity checks are downgraded for the duration of the transaction.

Returns:
Returns the report (only success messages).
Throws:
java.lang.Exception - anything can be thrown. This must be used for all failures.
See Also:
AbstractPatch.apply()

reportProgress

protected void reportProgress(long estimatedTotal,
                              long currentInteration)
Support to report patch completion and estimated completion time.

Parameters:
estimatedTotal -
currentInteration -


Copyright © 2005 - 2008 Alfresco Software, Inc. All Rights Reserved.