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;
}
};
};
}
/* (non-Javadoc)
@ -560,9 +560,9 @@ public class FileFolderServiceImpl extends AbstractBaseCopyService implements Fi
public NodeRef searchSimple(NodeRef contextNodeRef, String name)
{
ParameterCheck.mandatory("name", name);
ParameterCheck.mandatory("contextNodeRef", contextNodeRef);
ParameterCheck.mandatory("name", name);
ParameterCheck.mandatory("contextNodeRef", contextNodeRef);
NodeRef childNodeRef = nodeService.getChildByName(contextNodeRef, ContentModel.ASSOC_CONTAINS, name);
if (logger.isTraceEnabled())
{
@ -1009,15 +1009,15 @@ public class FileFolderServiceImpl extends AbstractBaseCopyService implements Fi
{
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))
{
assocTypeQname = ContentModel.ASSOC_CHILDREN; // sys:container -> sys:children
assocTypeQname = ContentModel.ASSOC_CHILDREN; // sys:container -> sys:children
}
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);
String newMimetype = mimetypeService.guessMimetype(newName, reader);
if (!targetMimetype.equalsIgnoreCase(newMimetype))
{
{
contentData = ContentData.setMimetype(contentData, newMimetype);
nodeService.setProperty(targetNodeRef, ContentModel.PROP_CONTENT, contentData);
}
}
}
}
catch (DuplicateChildNodeNameException e)

View File

@ -137,18 +137,18 @@ public interface NodeServicePolicies
}
@AlfrescoPublicApi
public interface OnUpdateNodePolicy extends ClassPolicy
{
public interface OnUpdateNodePolicy extends ClassPolicy
{
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
* associations and the addition of aspects.
*
* @param nodeRef reference to the updated node
*/
public void onUpdateNode(NodeRef nodeRef);
}
/**
* Called after a new node has been created. This includes the modification of properties, child and target
* associations and the addition of aspects.
*
* @param nodeRef reference to the updated node
*/
public void onUpdateNode(NodeRef nodeRef);
}
@AlfrescoPublicApi
public interface OnUpdatePropertiesPolicy extends ClassPolicy
{
@ -171,18 +171,18 @@ public interface NodeServicePolicies
}
@AlfrescoPublicApi
public interface BeforeDeleteNodePolicy extends ClassPolicy
{
public interface BeforeDeleteNodePolicy extends ClassPolicy
{
public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode");
/**
* Called before a node is deleted.
*
* @param nodeRef the node reference
*/
public void beforeDeleteNode(NodeRef nodeRef);
}
@AlfrescoPublicApi
/**
* Called before a node is deleted.
*
* @param nodeRef the node reference
*/
public void beforeDeleteNode(NodeRef nodeRef);
}
@AlfrescoPublicApi
public interface BeforeArchiveNodePolicy extends ClassPolicy
{
public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeArchiveNode");
@ -195,21 +195,21 @@ public interface NodeServicePolicies
}
@AlfrescoPublicApi
public interface OnDeleteNodePolicy extends ClassPolicy
{
public interface OnDeleteNodePolicy extends ClassPolicy
{
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
* information from any of the services.
*
* @param childAssocRef the primary parent-child association of the deleted node
* @param isNodeArchived indicates whether the node has been archived rather than purged
*/
public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived);
}
@AlfrescoPublicApi
*
* @param childAssocRef the primary parent-child association of the deleted node
* @param isNodeArchived indicates whether the node has been archived rather than purged
*/
public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived);
}
@AlfrescoPublicApi
public interface BeforeAddAspectPolicy extends ClassPolicy
{
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 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 String EXT_SITES_PREFERENCE_KEY = "org.alfresco.ext.sites.favourites.";
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.";
/** Node service */
private NodeService nodeService;
private ContentService contentService;
@ -76,7 +76,7 @@ public class PreferenceServiceImpl implements PreferenceService
private AuthenticationContext authenticationContext;
private AuthorityService authorityService;
/**
/**
* Set the node service
*
* @param nodeService the node service
@ -91,7 +91,7 @@ public class PreferenceServiceImpl implements PreferenceService
this.contentService = contentService;
}
/**
/**
* Set the person service
*
* @param personService the person service
@ -168,16 +168,16 @@ public class PreferenceServiceImpl implements PreferenceService
public Serializable getPreference(String userName, String preferenceName)
{
String preferenceValue = null;
String preferenceValue = null;
try
{
JSONObject jsonPrefs = getPreferencesObject(userName);
if(jsonPrefs != null)
{
if(jsonPrefs.has(preferenceName))
{
preferenceValue = jsonPrefs.getString(preferenceName);
}
JSONObject jsonPrefs = getPreferencesObject(userName);
if(jsonPrefs != null)
{
if(jsonPrefs.has(preferenceName))
{
preferenceValue = jsonPrefs.getString(preferenceName);
}
}
}
catch (JSONException exception)
@ -200,56 +200,56 @@ public class PreferenceServiceImpl implements PreferenceService
try
{
JSONObject jsonPrefs = getPreferencesObject(userName);
if(jsonPrefs != null)
{
// Build hash from preferences stored in the repository
Iterator<String> keys = jsonPrefs.keys();
while (keys.hasNext())
{
String key = (String)keys.next();
Serializable value = (Serializable)jsonPrefs.get(key);
JSONObject jsonPrefs = getPreferencesObject(userName);
if(jsonPrefs != null)
{
// Build hash from preferences stored in the repository
Iterator<String> keys = jsonPrefs.keys();
while (keys.hasNext())
{
String key = (String)keys.next();
Serializable value = (Serializable)jsonPrefs.get(key);
if(key.startsWith(SHARE_SITES_PREFERENCE_KEY))
{
// CLOUD-1518: convert site preferences on the fly
// convert keys as follows:
// <SHARE_SITES_PREFERENCE_KEY>.<siteId>.favourited -> <SHARE_SITES_PREFERENCE_KEY>.<siteId>
// <SHARE_SITES_PREFERENCE_KEY>.<siteId>.createdAt -> <EXT_SITES_PREFERENCE_KEY>.<siteId>.createdAt
if(key.endsWith(".favourited"))
{
int idx = key.indexOf(".favourited");
String siteId = key.substring(SHARE_SITES_PREFERENCE_KEY_LEN, idx);
StringBuilder sb = new StringBuilder(SHARE_SITES_PREFERENCE_KEY);
sb.append(siteId);
key = sb.toString();
}
else if(key.endsWith(".createdAt"))
{
int idx = key.indexOf(".createdAt");
String siteId = key.substring(SHARE_SITES_PREFERENCE_KEY_LEN, idx);
StringBuilder sb = new StringBuilder(EXT_SITES_PREFERENCE_KEY);
sb.append(siteId);
sb.append(".createdAt");
key = sb.toString();
}
else if(preferences.containsKey(key))
{
// 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:
// <SHARE_SITES_PREFERENCE_KEY>.<siteId>
continue;
}
}
if(key.startsWith(SHARE_SITES_PREFERENCE_KEY))
{
// CLOUD-1518: convert site preferences on the fly
// convert keys as follows:
// <SHARE_SITES_PREFERENCE_KEY>.<siteId>.favourited -> <SHARE_SITES_PREFERENCE_KEY>.<siteId>
// <SHARE_SITES_PREFERENCE_KEY>.<siteId>.createdAt -> <EXT_SITES_PREFERENCE_KEY>.<siteId>.createdAt
if(key.endsWith(".favourited"))
{
int idx = key.indexOf(".favourited");
String siteId = key.substring(SHARE_SITES_PREFERENCE_KEY_LEN, idx);
StringBuilder sb = new StringBuilder(SHARE_SITES_PREFERENCE_KEY);
sb.append(siteId);
key = sb.toString();
}
else if(key.endsWith(".createdAt"))
{
int idx = key.indexOf(".createdAt");
String siteId = key.substring(SHARE_SITES_PREFERENCE_KEY_LEN, idx);
StringBuilder sb = new StringBuilder(EXT_SITES_PREFERENCE_KEY);
sb.append(siteId);
sb.append(".createdAt");
key = sb.toString();
}
else if(preferences.containsKey(key))
{
// 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:
// <SHARE_SITES_PREFERENCE_KEY>.<siteId>
continue;
}
}
if (preferenceFilter == null ||
preferenceFilter.length() == 0 ||
matchPreferenceNames(key, preferenceFilter))
{
preferences.put(key, value);
}
}
if (preferenceFilter == null ||
preferenceFilter.length() == 0 ||
matchPreferenceNames(key, preferenceFilter))
{
preferences.put(key, value);
}
}
}
}
catch (JSONException exception)
@ -264,60 +264,60 @@ public class PreferenceServiceImpl implements PreferenceService
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 skipCount = pagingRequest.getSkipCount();
int maxItems = pagingRequest.getMaxItems();
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 List<Pair<String, Serializable>> page = new ArrayList<Pair<String, Serializable>>(pageSize);
Iterator<Map.Entry<String, Serializable>> it = prefs.entrySet().iterator();
final List<Pair<String, Serializable>> page = new ArrayList<Pair<String, Serializable>>(pageSize);
Iterator<Map.Entry<String, Serializable>> it = prefs.entrySet().iterator();
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)
{
continue;
}
if(counter > end - 1)
{
break;
}
if(counter < skipCount)
{
continue;
}
if(counter > end - 1)
{
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>>()
{
@Override
public List<Pair<String, Serializable>> getPage()
{
return page;
}
@Override
public List<Pair<String, Serializable>> getPage()
{
return page;
}
@Override
public boolean hasMoreItems()
{
return hasMoreItems;
}
@Override
public boolean hasMoreItems()
{
return hasMoreItems;
}
@Override
public Pair<Integer, Integer> getTotalResultCount()
{
Integer total = Integer.valueOf(prefs.size());
return new Pair<Integer, Integer>(total, total);
}
@Override
public Pair<Integer, Integer> getTotalResultCount()
{
Integer total = Integer.valueOf(prefs.size());
return new Pair<Integer, Integer>(total, total);
}
@Override
public String getQueryExecutionId()
{
return null;
}
@Override
public String getQueryExecutionId()
{
return null;
}
};
}
@ -340,7 +340,7 @@ public class PreferenceServiceImpl implements PreferenceService
if(matchToArr.length > nameArr.length)
{
return false;
return false;
}
int index = 0;
@ -399,39 +399,39 @@ public class PreferenceServiceImpl implements PreferenceService
// Update with the new preference values
for (Map.Entry<String, Serializable> entry : preferences.entrySet())
{
String key = entry.getKey();
String key = entry.getKey();
// CLOUD-1518: remove extraneous site preferences, if present
if(key.startsWith(SHARE_SITES_PREFERENCE_KEY))
{
// remove any extraneous keys, if present
String siteId = key.substring(SHARE_SITES_PREFERENCE_KEY_LEN);
// CLOUD-1518: remove extraneous site preferences, if present
if(key.startsWith(SHARE_SITES_PREFERENCE_KEY))
{
// remove any extraneous keys, if present
String siteId = key.substring(SHARE_SITES_PREFERENCE_KEY_LEN);
StringBuilder sb = new StringBuilder(SHARE_SITES_PREFERENCE_KEY);
sb.append(siteId);
sb.append(".favourited");
String testKey = sb.toString();
if(jsonPrefs.has(testKey))
{
jsonPrefs.remove(testKey);
}
sb = new StringBuilder(SHARE_SITES_PREFERENCE_KEY);
sb.append(siteId);
sb.append(".createdAt");
testKey = sb.toString();
if(jsonPrefs.has(testKey))
{
jsonPrefs.remove(testKey);
}
}
Serializable value = entry.getValue();
if(value != null && value.equals("CURRENT_DATE"))
{
Date date = new Date();
value = ISO8601DateFormat.format(date);
}
StringBuilder sb = new StringBuilder(SHARE_SITES_PREFERENCE_KEY);
sb.append(siteId);
sb.append(".favourited");
String testKey = sb.toString();
if(jsonPrefs.has(testKey))
{
jsonPrefs.remove(testKey);
}
sb = new StringBuilder(SHARE_SITES_PREFERENCE_KEY);
sb.append(siteId);
sb.append(".createdAt");
testKey = sb.toString();
if(jsonPrefs.has(testKey))
{
jsonPrefs.remove(testKey);
}
}
Serializable value = entry.getValue();
if(value != null && value.equals("CURRENT_DATE"))
{
Date date = new Date();
value = ISO8601DateFormat.format(date);
}
jsonPrefs.put(key, value);
}
@ -508,7 +508,7 @@ public class PreferenceServiceImpl implements PreferenceService
// Remove the prefs that match the filter
List<String> removeKeys = new ArrayList<String>(10);
@SuppressWarnings("unchecked")
Iterator<String> keys = jsonPrefs.keys();
Iterator<String> keys = jsonPrefs.keys();
while (keys.hasNext())
{
final String key = (String) keys.next();
@ -572,45 +572,45 @@ public class PreferenceServiceImpl implements PreferenceService
public static class PageDetails
{
private boolean hasMoreItems = false;
private int pageSize;
private int skipCount;
private int maxItems;
private int end;
private boolean hasMoreItems = false;
private int pageSize;
private int skipCount;
private int maxItems;
private int end;
public PageDetails(int pageSize, boolean hasMoreItems, int skipCount, int maxItems, int end)
{
super();
this.hasMoreItems = hasMoreItems;
this.pageSize = pageSize;
this.skipCount = skipCount;
this.maxItems = maxItems;
this.end = end;
}
public PageDetails(int pageSize, boolean hasMoreItems, int skipCount, int maxItems, int end)
{
super();
this.hasMoreItems = hasMoreItems;
this.pageSize = pageSize;
this.skipCount = skipCount;
this.maxItems = maxItems;
this.end = end;
}
public int getSkipCount()
{
return skipCount;
}
public int getSkipCount()
{
return skipCount;
}
public int getMaxItems()
{
return maxItems;
}
public int getMaxItems()
{
return maxItems;
}
public int getEnd()
{
return end;
}
public int getEnd()
{
return end;
}
public boolean hasMoreItems()
{
return hasMoreItems;
}
public boolean hasMoreItems()
{
return hasMoreItems;
}
public int getPageSize()
{
return pageSize;
}
public int getPageSize()
{
return pageSize;
}
}
}

View File

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