MNT-18340: no longer ignores property updates for "unrelated" aspect removal

https://issues.alfresco.com/jira/browse/MNT-18340
This commit is contained in:
Matt Ward
2017-09-20 16:28:49 +01:00
parent 344952540b
commit 2f16270e6f

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.opencmis;
import java.io.BufferedOutputStream;
@@ -50,17 +50,17 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.TimeZone;
import java.util.TreeSet;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.events.types.ContentEvent;
import org.alfresco.events.types.ContentEventImpl;
import org.alfresco.events.types.ContentReadRangeEvent;
import org.alfresco.events.types.Event;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.activities.ActivityInfo;
import org.alfresco.service.cmr.activities.ActivityInfo;
import org.alfresco.opencmis.dictionary.CMISActionEvaluator;
import org.alfresco.opencmis.dictionary.CMISAllowedActionEnum;
import org.alfresco.opencmis.dictionary.CMISDictionaryService;
@@ -81,8 +81,8 @@ import org.alfresco.opencmis.search.CMISResultSetRow;
import org.alfresco.repo.Client;
import org.alfresco.repo.Client.ClientType;
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.coci.CheckOutCheckInServiceImpl;
import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.coci.CheckOutCheckInServiceImpl;
import org.alfresco.repo.events.EventPreparator;
import org.alfresco.repo.events.EventPublisher;
import org.alfresco.repo.model.filefolder.GetChildrenCannedQuery;
@@ -462,22 +462,22 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
this.objectsDefaultDepth = objectsDefaultDepth;
}
/**
* Set the default number of content changes to return if nothing is specified
*/
public void setContentChangesDefaultMaxItems(int contentChangesDefaultMaxItems)
{
if (contentChangesDefaultMaxItems < 1)
{
throw new IllegalArgumentException("The default maximum number of content changes to retrieve must be greater than zero.");
}
else if (contentChangesDefaultMaxItems == Integer.MAX_VALUE)
{
throw new IllegalArgumentException("The server cannot return " + Integer.MAX_VALUE + " content changes in a request!");
}
this.contentChangesDefaultMaxItems = contentChangesDefaultMaxItems;
}
/**
* Set the default number of content changes to return if nothing is specified
*/
public void setContentChangesDefaultMaxItems(int contentChangesDefaultMaxItems)
{
if (contentChangesDefaultMaxItems < 1)
{
throw new IllegalArgumentException("The default maximum number of content changes to retrieve must be greater than zero.");
}
else if (contentChangesDefaultMaxItems == Integer.MAX_VALUE)
{
throw new IllegalArgumentException("The server cannot return " + Integer.MAX_VALUE + " content changes in a request!");
}
this.contentChangesDefaultMaxItems = contentChangesDefaultMaxItems;
}
/**
* Set rendition kind mapping.
*/
@@ -504,14 +504,14 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
public void setServiceRegistry(ServiceRegistry serviceRegistry)
{
this.serviceRegistry = serviceRegistry;
}
/**
* Return the service registry
*/
public final ServiceRegistry getServiceRegistry()
{
return this.serviceRegistry;
}
/**
* Return the service registry
*/
public final ServiceRegistry getServiceRegistry()
{
return this.serviceRegistry;
}
/**
@@ -3185,8 +3185,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
Set<QName> ignore = new HashSet<QName>();
ignore.add(ContentModel.ASPECT_REFERENCEABLE);
ignore.add(ContentModel.ASPECT_LOCALIZED);
ignore.add(ContentModel.ASPECT_WORKING_COPY);
ignore.add(ContentModel.ASPECT_LOCALIZED);
ignore.add(ContentModel.ASPECT_WORKING_COPY);
// aspects to add == the list of secondary types - existing aspects - ignored aspects
Set<QName> toAdd = new HashSet<QName>(secondaryTypeAspects);
@@ -3213,13 +3213,6 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
for(QName aspectQName : aspectsToRemove)
{
nodeService.removeAspect(nodeRef, aspectQName);
// aspect is being removed so remove all of its properties from the propsToAdd map
TypeDefinitionWrapper w = getOpenCMISDictionaryService().findNodeType(aspectQName);
for(PropertyDefinitionWrapper wr : w.getProperties())
{
String propertyId = wr.getPropertyId();
propsToAdd.remove(propertyId);
}
}
// add aspects and properties
@@ -3607,21 +3600,21 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
try
{
String newName = value.toString();
// If the node is checked out and the name property is set on the working copy, make sure the new name has the working copy format
if (checkOutCheckInService.isWorkingCopy(nodeRef))
{
String wcLabel = (String)this.nodeService.getProperty(nodeRef, ContentModel.PROP_WORKING_COPY_LABEL);
if (wcLabel == null)
{
wcLabel = CheckOutCheckInServiceImpl.getWorkingCopyLabel();
}
if (!newName.contains(wcLabel))
{
newName = CheckOutCheckInServiceImpl.createWorkingCopyName(newName, wcLabel);
}
}
{
String newName = value.toString();
// If the node is checked out and the name property is set on the working copy, make sure the new name has the working copy format
if (checkOutCheckInService.isWorkingCopy(nodeRef))
{
String wcLabel = (String)this.nodeService.getProperty(nodeRef, ContentModel.PROP_WORKING_COPY_LABEL);
if (wcLabel == null)
{
wcLabel = CheckOutCheckInServiceImpl.getWorkingCopyLabel();
}
if (!newName.contains(wcLabel))
{
newName = CheckOutCheckInServiceImpl.createWorkingCopyName(newName, wcLabel);
}
}
fileFolderService.rename(nodeRef, newName);
}
@@ -3709,30 +3702,30 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
params.setApplicationName(CMIS_CHANGELOG_AUDIT_APPLICATION);
params.setForward(true);
params.setFromId(from);
// So we have a BigInteger. We need to ensure that we cut it down to an integer smaller than Integer.MAX_VALUE
// So we have a BigInteger. We need to ensure that we cut it down to an integer smaller than Integer.MAX_VALUE
int maxResults = (maxItems == null ? contentChangesDefaultMaxItems : maxItems.intValue());
maxResults = maxResults < 1 ? contentChangesDefaultMaxItems : maxResults; // Just a double check of the unbundled contents
maxResults = maxResults > contentChangesDefaultMaxItems ? contentChangesDefaultMaxItems : maxResults; // cut it down
int maxResults = (maxItems == null ? contentChangesDefaultMaxItems : maxItems.intValue());
maxResults = maxResults < 1 ? contentChangesDefaultMaxItems : maxResults; // Just a double check of the unbundled contents
maxResults = maxResults > contentChangesDefaultMaxItems ? contentChangesDefaultMaxItems : maxResults; // cut it down
int queryFor = maxResults + 1; // Query for 1 more so that we know if there are more results
auditService.auditQuery(changeLogCollectingCallback, params, queryFor);
String newChangeLogToken = null;
String newChangeLogToken = null;
// Check if we got more than the client requested
if (result.getObjects().size() >= maxResults)
{
// Build the change log token from the last item
StringBuilder clt = new StringBuilder();
newChangeLogToken = (from == null ? clt.append(maxItems.intValue() + 1).toString() : clt.append(from.longValue() + maxItems.intValue()).toString()); // TODO: Make this readable
newChangeLogToken = (from == null ? clt.append(maxItems.intValue() + 1).toString() : clt.append(from.longValue() + maxItems.intValue()).toString()); // TODO: Make this readable
// Remove extra item that was not actually requested
result.getObjects().remove(result.getObjects().size() - 1).getId();
result.getObjects().remove(result.getObjects().size() - 1).getId();
// Note to client that there are more items
result.setHasMoreItems(true);
}
else
{
{
// We got the same or fewer than the number requested, so there are no more items
result.setHasMoreItems(false);
}