mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fixed ContentData ID node properties to use actual type CONTENT_DATA_ID
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20788 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1569,10 +1569,23 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
||||
// Remove sys:referenceable
|
||||
ReferenceablePropertiesEntity.removeReferenceableProperties(node, newProps);
|
||||
|
||||
// Get the old properties in the raw format, attempting a shortcut for new nodes
|
||||
Map<NodePropertyKey, NodePropertyValue> oldPropsRaw = null;
|
||||
Map<QName, Serializable> oldProps = propertiesCache.getValue(nodeId);
|
||||
if (oldProps != null && oldProps.isEmpty())
|
||||
{
|
||||
// Don't requery
|
||||
oldPropsRaw = Collections.emptyMap();
|
||||
isAddOnly = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldPropsRaw = selectNodeProperties(nodeId);
|
||||
}
|
||||
|
||||
// Determine which properties we are interested in. For addition of properties, we only
|
||||
// need the old properties for the QNames being added. For complete setting of properties,
|
||||
// we need the full set of old properties.
|
||||
Map<NodePropertyKey, NodePropertyValue> oldPropsRaw = selectNodeProperties(nodeId);
|
||||
Set<Long> qnameIdsOfInterest = qnameDAO.convertQNamesToIds(newProps.keySet(), true);
|
||||
|
||||
// Get new property raw values
|
||||
@@ -1617,7 +1630,7 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
||||
if (newContentData != null)
|
||||
{
|
||||
Long newContentDataId = contentDataDAO.createContentData(newContentData).getFirst();
|
||||
newPropValue = new NodePropertyValue(DataTypeDefinition.CONTENT, newContentDataId);
|
||||
newPropValue = new NodePropertyValue(DataTypeDefinition.CONTENT, new ContentDataId(newContentDataId));
|
||||
propsToAdd.put(key, newPropValue);
|
||||
}
|
||||
}
|
||||
@@ -1678,7 +1691,7 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
||||
if (newContentData != null)
|
||||
{
|
||||
Long newContentDataId = contentDataDAO.createContentData(newContentData).getFirst();
|
||||
newPropValue = new NodePropertyValue(DataTypeDefinition.CONTENT, newContentDataId);
|
||||
newPropValue = new NodePropertyValue(DataTypeDefinition.CONTENT, new ContentDataId(newContentDataId));
|
||||
propsToAdd.put(key, newPropValue);
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.domain;
|
||||
package org.alfresco.repo.domain.node;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 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.node;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
|
||||
/**
|
||||
* <code>ContentData</code>-derived class with ID.
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 3.4
|
||||
*/
|
||||
public class ContentDataWithId extends ContentData
|
||||
{
|
||||
private final Long id;
|
||||
|
||||
public ContentDataWithId(ContentData contentData, Long id)
|
||||
{
|
||||
super(contentData);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "ContentData [id=" + id + "]";
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
}
|
@@ -35,7 +35,6 @@ import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.domain.ContentDataId;
|
||||
import org.alfresco.repo.domain.contentdata.ContentDataDAO;
|
||||
import org.alfresco.repo.domain.locale.LocaleDAO;
|
||||
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||
@@ -252,18 +251,6 @@ public class NodePropertyHelper
|
||||
+ " Property: " + propertyDef + "\n" + " Type: " + propertyTypeQName + "\n"
|
||||
+ " Value: " + value);
|
||||
}
|
||||
// Handle ContentData
|
||||
// We used to check the property type, but we now handle d:any ContentData as well
|
||||
if (value instanceof ContentData)
|
||||
{
|
||||
// We keep the ContentData i.e. we treat it as a low-level property that will be handled externally.
|
||||
// This will be converted to a String and persisted as such unless the value is ultimately
|
||||
// replaced by and ID-based ContentData reference
|
||||
// // Needs converting to an ID
|
||||
// ContentData contentData = (ContentData) value;
|
||||
// Long contentDataId = contentDataDAO.createContentData(contentData).getFirst();
|
||||
// value = new ContentDataId(contentDataId);
|
||||
}
|
||||
// Handle MLText
|
||||
if (value instanceof MLText)
|
||||
{
|
||||
@@ -618,30 +605,14 @@ public class NodePropertyHelper
|
||||
// ContentData used to be persisted as a String and then as a Long.
|
||||
// Now it has a special type to denote the ID
|
||||
Long contentDataId = ((ContentDataId) value).getId();
|
||||
Pair<Long, ContentData> contentDataPair = contentDataDAO.getContentData(contentDataId);
|
||||
if (contentDataPair == null)
|
||||
{
|
||||
// It is invalid
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = contentDataPair.getSecond();
|
||||
}
|
||||
ContentData contentData = contentDataDAO.getContentData(contentDataId).getSecond();
|
||||
value = new ContentDataWithId(contentData, contentDataId);
|
||||
}
|
||||
else if (propertyTypeQName.equals(DataTypeDefinition.CONTENT) && (value instanceof Long))
|
||||
else if ((value instanceof Long) && propertyTypeQName.equals(DataTypeDefinition.CONTENT))
|
||||
{
|
||||
// ContentData used to be persisted
|
||||
Pair<Long, ContentData> contentDataPair = contentDataDAO.getContentData((Long) value);
|
||||
if (contentDataPair == null)
|
||||
{
|
||||
// It is invalid
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = contentDataPair.getSecond();
|
||||
}
|
||||
Long contentDataId = (Long) value;
|
||||
ContentData contentData = contentDataDAO.getContentData(contentDataId).getSecond();
|
||||
value = new ContentDataWithId(contentData, contentDataId);
|
||||
}
|
||||
// done
|
||||
return value;
|
||||
|
@@ -37,7 +37,6 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.domain.ContentDataId;
|
||||
import org.alfresco.repo.domain.schema.SchemaBootstrap;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
@@ -50,10 +49,10 @@ import org.alfresco.service.cmr.repository.Period;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
import org.alfresco.util.VersionNumber;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Immutable property value storage class.
|
||||
|
Reference in New Issue
Block a user