Fix renaming of 'Company Home' and other system folders such as Data Dictionary - AR-318

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2045 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2005-12-16 13:58:25 +00:00
parent 6171b6ae11
commit facd631cce
2 changed files with 50 additions and 7 deletions

View File

@@ -12,6 +12,15 @@
<property name="searchService"><ref bean="SearchService" /></property> <property name="searchService"><ref bean="SearchService" /></property>
<property name="contentService"><ref bean="contentService" /></property> <property name="contentService"><ref bean="contentService" /></property>
<property name="mimetypeService"><ref bean="mimetypeMap" /></property> <property name="mimetypeService"><ref bean="mimetypeMap" /></property>
<property name="systemPaths">
<list>
<value>/${spaces.company_home.childname}</value>
<value>/${spaces.company_home.childname}/${spaces.dictionary.childname}</value>
<value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.childname}</value>
<value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.content.childname}</value>
</list>
</property>
</bean> </bean>
</beans> </beans>

View File

@@ -98,6 +98,9 @@ public class FileFolderServiceImpl implements FileFolderService
private ContentService contentService; private ContentService contentService;
private MimetypeService mimetypeService; private MimetypeService mimetypeService;
// TODO: Replace this with a more formal means of identifying "system" folders (i.e. aspect or UUID)
private List systemPaths;
/** /**
* Default constructor * Default constructor
*/ */
@@ -140,6 +143,13 @@ public class FileFolderServiceImpl implements FileFolderService
this.mimetypeService = mimetypeService; this.mimetypeService = mimetypeService;
} }
// TODO: Replace this with a more formal means of identifying "system" folders (i.e. aspect or UUID)
public void setSystemPaths(List<String> systemPaths)
{
this.systemPaths = systemPaths;
}
public void init() public void init()
{ {
PARAMS_ANY_NAME[0] = new QueryParameterDefImpl( PARAMS_ANY_NAME[0] = new QueryParameterDefImpl(
@@ -480,6 +490,9 @@ public class FileFolderServiceImpl implements FileFolderService
// move or copy // move or copy
NodeRef targetNodeRef = null; NodeRef targetNodeRef = null;
if (move) if (move)
{
// TODO: Replace this with a more formal means of identifying "system" folders (i.e. aspect or UUID)
if (!isSystemPath(sourceNodeRef))
{ {
// move the node so that the association moves as well // move the node so that the association moves as well
ChildAssociationRef newAssocRef = nodeService.moveNode( ChildAssociationRef newAssocRef = nodeService.moveNode(
@@ -490,6 +503,12 @@ public class FileFolderServiceImpl implements FileFolderService
targetNodeRef = newAssocRef.getChildRef(); targetNodeRef = newAssocRef.getChildRef();
} }
else else
{
// system path folders do not need to be moved
targetNodeRef = sourceNodeRef;
}
}
else
{ {
// copy the node // copy the node
targetNodeRef = copyService.copy( targetNodeRef = copyService.copy(
@@ -515,6 +534,21 @@ public class FileFolderServiceImpl implements FileFolderService
return afterFileInfo; return afterFileInfo;
} }
/**
* Determine if the specified node is a special "system" folder path based node
*
* TODO: Replace this with a more formal means of identifying "system" folders (i.e. aspect or UUID)
*
* @param nodeRef node to check
* @return true => system folder path based node
*/
private boolean isSystemPath(NodeRef nodeRef)
{
Path path = nodeService.getPath(nodeRef);
String prefixedPath = path.toPrefixString(namespaceService);
return systemPaths.contains(prefixedPath);
}
public FileInfo create(NodeRef parentNodeRef, String name, QName typeQName) throws FileExistsException public FileInfo create(NodeRef parentNodeRef, String name, QName typeQName) throws FileExistsException
{ {
// file or folder // file or folder