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

57053: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3)
      56520: Merged HEAD-BUG-FIX to V4.2-BUG-FIX (4.2.1)
         56403: Various format fixes made during investigations e.g. ALF-20221


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61687 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2014-02-11 19:01:50 +00:00
parent f4cdcb412a
commit 1a05b428a3
4 changed files with 209 additions and 207 deletions

View File

@@ -401,7 +401,7 @@ public class FileFolderServiceImpl extends AbstractBaseCopyService implements Fi
{ {
return totalCount; return totalCount;
} }
}; };
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -560,9 +560,9 @@ public class FileFolderServiceImpl extends AbstractBaseCopyService implements Fi
public NodeRef searchSimple(NodeRef contextNodeRef, String name) public NodeRef searchSimple(NodeRef contextNodeRef, String name)
{ {
ParameterCheck.mandatory("name", name); ParameterCheck.mandatory("name", name);
ParameterCheck.mandatory("contextNodeRef", contextNodeRef); ParameterCheck.mandatory("contextNodeRef", contextNodeRef);
NodeRef childNodeRef = nodeService.getChildByName(contextNodeRef, ContentModel.ASSOC_CONTAINS, name); NodeRef childNodeRef = nodeService.getChildByName(contextNodeRef, ContentModel.ASSOC_CONTAINS, name);
if (logger.isTraceEnabled()) if (logger.isTraceEnabled())
{ {
@@ -1009,15 +1009,15 @@ public class FileFolderServiceImpl extends AbstractBaseCopyService implements Fi
{ {
if (dictionaryService.isSubClass(targetParentType, ContentModel.TYPE_FOLDER)) if (dictionaryService.isSubClass(targetParentType, ContentModel.TYPE_FOLDER))
{ {
assocTypeQname = ContentModel.ASSOC_CONTAINS; // cm:folder -> cm:contains assocTypeQname = ContentModel.ASSOC_CONTAINS; // cm:folder -> cm:contains
} }
else if (dictionaryService.isSubClass(targetParentType, ContentModel.TYPE_CONTAINER)) else if (dictionaryService.isSubClass(targetParentType, ContentModel.TYPE_CONTAINER))
{ {
assocTypeQname = ContentModel.ASSOC_CHILDREN; // sys:container -> sys:children assocTypeQname = ContentModel.ASSOC_CHILDREN; // sys:container -> sys:children
} }
else else
{ {
throw new InvalidTypeException("Unexpected type (" + targetParentType + ") for target parent: " + targetParentRef); throw new InvalidTypeException("Unexpected type (" + targetParentType + ") for target parent: " + targetParentRef);
} }
} }
@@ -1126,10 +1126,10 @@ public class FileFolderServiceImpl extends AbstractBaseCopyService implements Fi
final ContentReader reader = contentService.getReader(targetNodeRef, ContentModel.PROP_CONTENT); final ContentReader reader = contentService.getReader(targetNodeRef, ContentModel.PROP_CONTENT);
String newMimetype = mimetypeService.guessMimetype(newName, reader); String newMimetype = mimetypeService.guessMimetype(newName, reader);
if (!targetMimetype.equalsIgnoreCase(newMimetype)) if (!targetMimetype.equalsIgnoreCase(newMimetype))
{ {
contentData = ContentData.setMimetype(contentData, newMimetype); contentData = ContentData.setMimetype(contentData, newMimetype);
nodeService.setProperty(targetNodeRef, ContentModel.PROP_CONTENT, contentData); nodeService.setProperty(targetNodeRef, ContentModel.PROP_CONTENT, contentData);
} }
} }
} }
catch (DuplicateChildNodeNameException e) catch (DuplicateChildNodeNameException e)

View File

@@ -137,18 +137,18 @@ public interface NodeServicePolicies
} }
@AlfrescoPublicApi @AlfrescoPublicApi
public interface OnUpdateNodePolicy extends ClassPolicy public interface OnUpdateNodePolicy extends ClassPolicy
{ {
public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateNode"); public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateNode");
/** /**
* Called after a new node has been created. This includes the modification of properties, child and target * Called after a new node has been created. This includes the modification of properties, child and target
* associations and the addition of aspects. * associations and the addition of aspects.
* *
* @param nodeRef reference to the updated node * @param nodeRef reference to the updated node
*/ */
public void onUpdateNode(NodeRef nodeRef); public void onUpdateNode(NodeRef nodeRef);
} }
@AlfrescoPublicApi @AlfrescoPublicApi
public interface OnUpdatePropertiesPolicy extends ClassPolicy public interface OnUpdatePropertiesPolicy extends ClassPolicy
{ {
@@ -171,18 +171,18 @@ public interface NodeServicePolicies
} }
@AlfrescoPublicApi @AlfrescoPublicApi
public interface BeforeDeleteNodePolicy extends ClassPolicy public interface BeforeDeleteNodePolicy extends ClassPolicy
{ {
public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"); public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode");
/** /**
* Called before a node is deleted. * Called before a node is deleted.
* *
* @param nodeRef the node reference * @param nodeRef the node reference
*/ */
public void beforeDeleteNode(NodeRef nodeRef); public void beforeDeleteNode(NodeRef nodeRef);
} }
@AlfrescoPublicApi @AlfrescoPublicApi
public interface BeforeArchiveNodePolicy extends ClassPolicy public interface BeforeArchiveNodePolicy extends ClassPolicy
{ {
public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeArchiveNode"); public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeArchiveNode");
@@ -195,21 +195,21 @@ public interface NodeServicePolicies
} }
@AlfrescoPublicApi @AlfrescoPublicApi
public interface OnDeleteNodePolicy extends ClassPolicy public interface OnDeleteNodePolicy extends ClassPolicy
{ {
public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"); public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode");
/** /**
* Called after a node is deleted. The reference given is for an association * Called after a node is deleted. The reference given is for an association
* which has been deleted and cannot be used to retrieve node or associaton * which has been deleted and cannot be used to retrieve node or associaton
* information from any of the services. * information from any of the services.
* *
* @param childAssocRef the primary parent-child association of the deleted node * @param childAssocRef the primary parent-child association of the deleted node
* @param isNodeArchived indicates whether the node has been archived rather than purged * @param isNodeArchived indicates whether the node has been archived rather than purged
*/ */
public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived); public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived);
} }
@AlfrescoPublicApi @AlfrescoPublicApi
public interface BeforeAddAspectPolicy extends ClassPolicy public interface BeforeAddAspectPolicy extends ClassPolicy
{ {
public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeAddAspect"); public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeAddAspect");

View File

@@ -63,9 +63,9 @@ public class PreferenceServiceImpl implements PreferenceService
private static final Log log = LogFactory.getLog(PreferenceServiceImpl.class); private static final Log log = LogFactory.getLog(PreferenceServiceImpl.class);
private static final String SHARE_SITES_PREFERENCE_KEY = "org.alfresco.share.sites.favourites."; private static final String SHARE_SITES_PREFERENCE_KEY = "org.alfresco.share.sites.favourites.";
private static final int SHARE_SITES_PREFERENCE_KEY_LEN = SHARE_SITES_PREFERENCE_KEY.length(); private static final int SHARE_SITES_PREFERENCE_KEY_LEN = SHARE_SITES_PREFERENCE_KEY.length();
private static final String EXT_SITES_PREFERENCE_KEY = "org.alfresco.ext.sites.favourites."; private static final String EXT_SITES_PREFERENCE_KEY = "org.alfresco.ext.sites.favourites.";
/** Node service */ /** Node service */
private NodeService nodeService; private NodeService nodeService;
private ContentService contentService; private ContentService contentService;
@@ -76,7 +76,7 @@ public class PreferenceServiceImpl implements PreferenceService
private AuthenticationContext authenticationContext; private AuthenticationContext authenticationContext;
private AuthorityService authorityService; private AuthorityService authorityService;
/** /**
* Set the node service * Set the node service
* *
* @param nodeService the node service * @param nodeService the node service
@@ -91,7 +91,7 @@ public class PreferenceServiceImpl implements PreferenceService
this.contentService = contentService; this.contentService = contentService;
} }
/** /**
* Set the person service * Set the person service
* *
* @param personService the person service * @param personService the person service
@@ -168,16 +168,16 @@ public class PreferenceServiceImpl implements PreferenceService
public Serializable getPreference(String userName, String preferenceName) public Serializable getPreference(String userName, String preferenceName)
{ {
String preferenceValue = null; String preferenceValue = null;
try try
{ {
JSONObject jsonPrefs = getPreferencesObject(userName); JSONObject jsonPrefs = getPreferencesObject(userName);
if(jsonPrefs != null) if(jsonPrefs != null)
{ {
if(jsonPrefs.has(preferenceName)) if(jsonPrefs.has(preferenceName))
{ {
preferenceValue = jsonPrefs.getString(preferenceName); preferenceValue = jsonPrefs.getString(preferenceName);
} }
} }
} }
catch (JSONException exception) catch (JSONException exception)
@@ -200,56 +200,56 @@ public class PreferenceServiceImpl implements PreferenceService
try try
{ {
JSONObject jsonPrefs = getPreferencesObject(userName); JSONObject jsonPrefs = getPreferencesObject(userName);
if(jsonPrefs != null) if(jsonPrefs != null)
{ {
// Build hash from preferences stored in the repository // Build hash from preferences stored in the repository
Iterator<String> keys = jsonPrefs.keys(); Iterator<String> keys = jsonPrefs.keys();
while (keys.hasNext()) while (keys.hasNext())
{ {
String key = (String)keys.next(); String key = (String)keys.next();
Serializable value = (Serializable)jsonPrefs.get(key); Serializable value = (Serializable)jsonPrefs.get(key);
if(key.startsWith(SHARE_SITES_PREFERENCE_KEY)) if(key.startsWith(SHARE_SITES_PREFERENCE_KEY))
{ {
// CLOUD-1518: convert site preferences on the fly // CLOUD-1518: convert site preferences on the fly
// convert keys as follows: // convert keys as follows:
// <SHARE_SITES_PREFERENCE_KEY>.<siteId>.favourited -> <SHARE_SITES_PREFERENCE_KEY>.<siteId> // <SHARE_SITES_PREFERENCE_KEY>.<siteId>.favourited -> <SHARE_SITES_PREFERENCE_KEY>.<siteId>
// <SHARE_SITES_PREFERENCE_KEY>.<siteId>.createdAt -> <EXT_SITES_PREFERENCE_KEY>.<siteId>.createdAt // <SHARE_SITES_PREFERENCE_KEY>.<siteId>.createdAt -> <EXT_SITES_PREFERENCE_KEY>.<siteId>.createdAt
if(key.endsWith(".favourited")) if(key.endsWith(".favourited"))
{ {
int idx = key.indexOf(".favourited"); int idx = key.indexOf(".favourited");
String siteId = key.substring(SHARE_SITES_PREFERENCE_KEY_LEN, idx); String siteId = key.substring(SHARE_SITES_PREFERENCE_KEY_LEN, idx);
StringBuilder sb = new StringBuilder(SHARE_SITES_PREFERENCE_KEY); StringBuilder sb = new StringBuilder(SHARE_SITES_PREFERENCE_KEY);
sb.append(siteId); sb.append(siteId);
key = sb.toString(); key = sb.toString();
} }
else if(key.endsWith(".createdAt")) else if(key.endsWith(".createdAt"))
{ {
int idx = key.indexOf(".createdAt"); int idx = key.indexOf(".createdAt");
String siteId = key.substring(SHARE_SITES_PREFERENCE_KEY_LEN, idx); String siteId = key.substring(SHARE_SITES_PREFERENCE_KEY_LEN, idx);
StringBuilder sb = new StringBuilder(EXT_SITES_PREFERENCE_KEY); StringBuilder sb = new StringBuilder(EXT_SITES_PREFERENCE_KEY);
sb.append(siteId); sb.append(siteId);
sb.append(".createdAt"); sb.append(".createdAt");
key = sb.toString(); key = sb.toString();
} }
else if(preferences.containsKey(key)) else if(preferences.containsKey(key))
{ {
// Ensure that the values of the following form (the only other important form in this case) does not // Ensure that the values of the following form (the only other important form in this case) does not
// override those on the lhs from above: // override those on the lhs from above:
// <SHARE_SITES_PREFERENCE_KEY>.<siteId> // <SHARE_SITES_PREFERENCE_KEY>.<siteId>
continue; continue;
} }
} }
if (preferenceFilter == null || if (preferenceFilter == null ||
preferenceFilter.length() == 0 || preferenceFilter.length() == 0 ||
matchPreferenceNames(key, preferenceFilter)) matchPreferenceNames(key, preferenceFilter))
{ {
preferences.put(key, value); preferences.put(key, value);
} }
} }
} }
} }
catch (JSONException exception) catch (JSONException exception)
@@ -264,60 +264,60 @@ public class PreferenceServiceImpl implements PreferenceService
public PagingResults<Pair<String, Serializable>> getPagedPreferences(String userName, String preferenceFilter, PagingRequest pagingRequest) public PagingResults<Pair<String, Serializable>> getPagedPreferences(String userName, String preferenceFilter, PagingRequest pagingRequest)
{ {
final Map<String, Serializable> prefs = getPreferences(userName, preferenceFilter); final Map<String, Serializable> prefs = getPreferences(userName, preferenceFilter);
int totalSize = prefs.size(); int totalSize = prefs.size();
int skipCount = pagingRequest.getSkipCount(); int skipCount = pagingRequest.getSkipCount();
int maxItems = pagingRequest.getMaxItems(); int maxItems = pagingRequest.getMaxItems();
int end = maxItems == CannedQueryPageDetails.DEFAULT_PAGE_SIZE ? totalSize : skipCount + maxItems; int end = maxItems == CannedQueryPageDetails.DEFAULT_PAGE_SIZE ? totalSize : skipCount + maxItems;
int pageSize = (maxItems == CannedQueryPageDetails.DEFAULT_PAGE_SIZE ? totalSize : Math.max(maxItems, totalSize - skipCount)); int pageSize = (maxItems == CannedQueryPageDetails.DEFAULT_PAGE_SIZE ? totalSize : Math.max(maxItems, totalSize - skipCount));
final boolean hasMoreItems = end < totalSize; final boolean hasMoreItems = end < totalSize;
final List<Pair<String, Serializable>> page = new ArrayList<Pair<String, Serializable>>(pageSize); final List<Pair<String, Serializable>> page = new ArrayList<Pair<String, Serializable>>(pageSize);
Iterator<Map.Entry<String, Serializable>> it = prefs.entrySet().iterator(); Iterator<Map.Entry<String, Serializable>> it = prefs.entrySet().iterator();
for(int counter = 0; counter < end && it.hasNext(); counter++) for(int counter = 0; counter < end && it.hasNext(); counter++)
{ {
Map.Entry<String, Serializable> pref = it.next(); Map.Entry<String, Serializable> pref = it.next();
if(counter < skipCount) if(counter < skipCount)
{ {
continue; continue;
} }
if(counter > end - 1) if(counter > end - 1)
{ {
break; break;
} }
page.add(new Pair<String, Serializable>(pref.getKey(), pref.getValue())); page.add(new Pair<String, Serializable>(pref.getKey(), pref.getValue()));
} }
return new PagingResults<Pair<String, Serializable>>() return new PagingResults<Pair<String, Serializable>>()
{ {
@Override @Override
public List<Pair<String, Serializable>> getPage() public List<Pair<String, Serializable>> getPage()
{ {
return page; return page;
} }
@Override @Override
public boolean hasMoreItems() public boolean hasMoreItems()
{ {
return hasMoreItems; return hasMoreItems;
} }
@Override @Override
public Pair<Integer, Integer> getTotalResultCount() public Pair<Integer, Integer> getTotalResultCount()
{ {
Integer total = Integer.valueOf(prefs.size()); Integer total = Integer.valueOf(prefs.size());
return new Pair<Integer, Integer>(total, total); return new Pair<Integer, Integer>(total, total);
} }
@Override @Override
public String getQueryExecutionId() public String getQueryExecutionId()
{ {
return null; return null;
} }
}; };
} }
@@ -340,7 +340,7 @@ public class PreferenceServiceImpl implements PreferenceService
if(matchToArr.length > nameArr.length) if(matchToArr.length > nameArr.length)
{ {
return false; return false;
} }
int index = 0; int index = 0;
@@ -399,39 +399,39 @@ public class PreferenceServiceImpl implements PreferenceService
// Update with the new preference values // Update with the new preference values
for (Map.Entry<String, Serializable> entry : preferences.entrySet()) for (Map.Entry<String, Serializable> entry : preferences.entrySet())
{ {
String key = entry.getKey(); String key = entry.getKey();
// CLOUD-1518: remove extraneous site preferences, if present // CLOUD-1518: remove extraneous site preferences, if present
if(key.startsWith(SHARE_SITES_PREFERENCE_KEY)) if(key.startsWith(SHARE_SITES_PREFERENCE_KEY))
{ {
// remove any extraneous keys, if present // remove any extraneous keys, if present
String siteId = key.substring(SHARE_SITES_PREFERENCE_KEY_LEN); String siteId = key.substring(SHARE_SITES_PREFERENCE_KEY_LEN);
StringBuilder sb = new StringBuilder(SHARE_SITES_PREFERENCE_KEY); StringBuilder sb = new StringBuilder(SHARE_SITES_PREFERENCE_KEY);
sb.append(siteId); sb.append(siteId);
sb.append(".favourited"); sb.append(".favourited");
String testKey = sb.toString(); String testKey = sb.toString();
if(jsonPrefs.has(testKey)) if(jsonPrefs.has(testKey))
{ {
jsonPrefs.remove(testKey); jsonPrefs.remove(testKey);
} }
sb = new StringBuilder(SHARE_SITES_PREFERENCE_KEY); sb = new StringBuilder(SHARE_SITES_PREFERENCE_KEY);
sb.append(siteId); sb.append(siteId);
sb.append(".createdAt"); sb.append(".createdAt");
testKey = sb.toString(); testKey = sb.toString();
if(jsonPrefs.has(testKey)) if(jsonPrefs.has(testKey))
{ {
jsonPrefs.remove(testKey); jsonPrefs.remove(testKey);
} }
} }
Serializable value = entry.getValue(); Serializable value = entry.getValue();
if(value != null && value.equals("CURRENT_DATE")) if(value != null && value.equals("CURRENT_DATE"))
{ {
Date date = new Date(); Date date = new Date();
value = ISO8601DateFormat.format(date); value = ISO8601DateFormat.format(date);
} }
jsonPrefs.put(key, value); jsonPrefs.put(key, value);
} }
@@ -508,7 +508,7 @@ public class PreferenceServiceImpl implements PreferenceService
// Remove the prefs that match the filter // Remove the prefs that match the filter
List<String> removeKeys = new ArrayList<String>(10); List<String> removeKeys = new ArrayList<String>(10);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Iterator<String> keys = jsonPrefs.keys(); Iterator<String> keys = jsonPrefs.keys();
while (keys.hasNext()) while (keys.hasNext())
{ {
final String key = (String) keys.next(); final String key = (String) keys.next();
@@ -572,45 +572,45 @@ public class PreferenceServiceImpl implements PreferenceService
public static class PageDetails public static class PageDetails
{ {
private boolean hasMoreItems = false; private boolean hasMoreItems = false;
private int pageSize; private int pageSize;
private int skipCount; private int skipCount;
private int maxItems; private int maxItems;
private int end; private int end;
public PageDetails(int pageSize, boolean hasMoreItems, int skipCount, int maxItems, int end) public PageDetails(int pageSize, boolean hasMoreItems, int skipCount, int maxItems, int end)
{ {
super(); super();
this.hasMoreItems = hasMoreItems; this.hasMoreItems = hasMoreItems;
this.pageSize = pageSize; this.pageSize = pageSize;
this.skipCount = skipCount; this.skipCount = skipCount;
this.maxItems = maxItems; this.maxItems = maxItems;
this.end = end; this.end = end;
} }
public int getSkipCount() public int getSkipCount()
{ {
return skipCount; return skipCount;
} }
public int getMaxItems() public int getMaxItems()
{ {
return maxItems; return maxItems;
} }
public int getEnd() public int getEnd()
{ {
return end; return end;
} }
public boolean hasMoreItems() public boolean hasMoreItems()
{ {
return hasMoreItems; return hasMoreItems;
} }
public int getPageSize() public int getPageSize()
{ {
return pageSize; return pageSize;
} }
} }
} }

View File

@@ -1123,6 +1123,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
public void beforeDeleteNode(NodeRef nodeRef) public void beforeDeleteNode(NodeRef nodeRef)
{ {
// Get the node's properties
nodeService.getProperties(nodeRef);
// add the child to the list // add the child to the list
beforeDeleteNodeRefs.add(nodeRef); beforeDeleteNodeRefs.add(nodeRef);