Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

108043: Merged 5.0.N (5.0.3) to HEAD-BUG-FIX (5.1/Cloud)
      107697: Merged DEV to 5.0.N (5.0.3)
         107623: MNT-14125: Errors related to sizeCurrent property.
            - Update actual_type_n and persisted_type_n to 3 (stands for long type) of cm:sizeCurrent properties which have invalid 0 types


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@108074 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-07-09 22:12:02 +00:00
parent 3fd4104605
commit 0b09d68864
7 changed files with 106 additions and 3 deletions

View File

@@ -73,6 +73,10 @@
<parameter property="maxNodeId" jdbcType="BIGINT" javaType="java.lang.Long"/>
</parameterMap>
<parameterMap id="parameter_fixSizeCurrentType" type="map">
<parameter property="sizeCurrentQNameId" jdbcType="BIGINT" javaType="java.lang.Long"/>
</parameterMap>
<!-- -->
<!-- Selects -->
<!-- -->
@@ -262,6 +266,15 @@
content_mimetype_id = ?
</update>
<update id="update_fixSizeCurrentType" parameterMap="parameter_fixSizeCurrentType">
update
alf_node_properties
set
actual_type_n = 3, persisted_type_n = 3
where
qname_id = #{sizeCurrentQNameId} AND (actual_type_n = 0 OR persisted_type_n = 0)
</update>
<!-- -->
<!-- Deletes -->
<!-- -->

View File

@@ -29,6 +29,9 @@ patch.genericMimetypeUpdate.indexed=\n\tIndexed {0} nodes in store ''{1}''.
patch.genericMimetypeUpdate.done=\n\tFinished updating mimetypes.
patch.genericMimetypeUpdate.doneReindex=\n\tFinished updating mimetypes. Selective reindexing was disabled; a reindex is required to search for the new mimetype(s).
patch.fixPersonSizeCurrentType.start=Fixing sizeCurrent type.
patch.fixPersonSizeCurrentType.done=\n\tFixed {0} sizeCurrent properties.
patch.noOpPatch.description=A placeholder patch; usually marks a superceded patch.
patch.noOpPatch.result=No-op patch
@@ -214,6 +217,8 @@ patch.updateMimetypesSVG.description=Fix mimetype for SVG Image
patch.updateMimetypesVISIO.description=Fix mimetype for Microsoft Visio
patch.updateMimetypesSVG.description=Fix mimetype for Scalable Vector Graphics Image
patch.fixPersonSizeCurrentType.description=Fix type of cm:sizeCurrent property.
patch.db-V3.2-AddFKIndexes.description=Fixes ALF-3189: Added missing FK indexes. Note: The script is empty for MySQL.
patch.migrateAttrTenants.description=Migrate old Tenant attributes

View File

@@ -1171,7 +1171,6 @@
</props>
</property>
</bean>
<bean id="patch.db-V5.1-metadata-query-indexes" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
<property name="id"><value>patch.db-V5.1-metadata-query-indexes</value></property>
<property name="description"><value>patch.db-V5.1-metadata-query-indexes.description</value></property>
@@ -1184,4 +1183,14 @@
</property>
</bean>
<bean id="patch.fixPersonSizeCurrentType" class="org.alfresco.repo.admin.patch.impl.FixPersonSizeCurrentTypePatch" parent="basePatch" >
<property name="id"><value>patch.fixPersonSizeCurrentType</value></property>
<property name="description"><value>patch.fixPersonSizeCurrentType.description</value></property>
<property name="fixesFromSchema"><value>0</value></property>
<property name="fixesToSchema"><value>9007</value></property>
<property name="targetSchema"><value>9008</value></property>
<property name="patchDAO">
<ref bean="patchDAO"/>
</property>
</bean>
</beans>

View File

@@ -23,4 +23,4 @@ version.build=r@scm-revision@-b@build-number@
# Schema number
version.schema=9007
version.schema=9008

View File

@@ -0,0 +1,59 @@
/*
* Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.admin.patch.impl;
import org.alfresco.repo.admin.patch.AbstractPatch;
import org.alfresco.repo.domain.patch.PatchDAO;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* A patch to update the 'actual_type_n' and 'persisted_type_n' of {http://www.alfresco.org/model/content/1.0}sizeCurrent
* property to be Long (3).
* <p>
*
* @author Viachaslau Tsikhanovich
*/
public class FixPersonSizeCurrentTypePatch extends AbstractPatch
{
private static final String MSG_START = "patch.fixPersonSizeCurrentType.start";
private static final String MSG_DONE = "patch.fixPersonSizeCurrentType.done";
private PatchDAO patchDAO;
public void setPatchDAO(PatchDAO patchDAO)
{
this.patchDAO = patchDAO;
}
protected void checkProperties()
{
super.checkProperties();
checkPropertyNotNull(patchDAO, "patchDAO");
}
@Override
protected String applyInternal() throws Exception
{
StringBuilder result = new StringBuilder(I18NUtil.getMessage(MSG_START));
int updateCount = patchDAO.updatePersonSizeCurrentType();
result.append(I18NUtil.getMessage(MSG_DONE, updateCount));
return result.toString();
}
}

View File

@@ -47,6 +47,13 @@ public interface PatchDAO
*/
public int updateContentMimetypeIds(Long oldMimetypeId, Long newMimetypeId);
/**
* Update all <b>alf_node_properties</b> of 'sizeCurrent' name to have correct persisted type of Long.
*
* @return the number of rows affected
*/
public int updatePersonSizeCurrentType();
/**
* Query for a list of nodes that have a given type and share the same name pattern (SQL LIKE syntax)
*

View File

@@ -59,6 +59,7 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl
private static final String SELECT_NODES_BY_TYPE_AND_NAME_PATTERN = "alfresco.patch.select_nodesByTypeAndNamePattern";
private static final String UPDATE_CONTENT_MIMETYPE_ID = "alfresco.patch.update_contentMimetypeId";
private static final String UPDATE_PERSON_SIZECURRENT_TYPE = "alfresco.patch.update_fixSizeCurrentType";
private static final String SELECT_COUNT_NODES_WITH_ASPECTS = "alfresco.patch.select_CountNodesWithAspectIds";
@@ -145,6 +146,15 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl
return template.update(UPDATE_CONTENT_MIMETYPE_ID, params);
}
@Override
public int updatePersonSizeCurrentType()
{
Map<String, Object> params = new HashMap<String, Object>(2);
Long sizeCurrentPropQNameId = qnameDAO.getOrCreateQName(ContentModel.PROP_SIZE_CURRENT).getFirst();
params.put("sizeCurrentQNameId", sizeCurrentPropQNameId);
return template.update(UPDATE_PERSON_SIZECURRENT_TYPE, params);
}
@Override
public List<Pair<NodeRef, String>> getNodesOfTypeWithNamePattern(QName typeQName, String namePattern)
{