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

@@ -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)
{