diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 4371b70c0a..aeebe538fb 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -595,6 +595,7 @@ system_props=System Properties hide_details=Hide Details show_details=Show Details user_search_info=To find a user search for them using their first name, last name and/or user name. Alternatively to see all users click 'Show All', however, this may take some time if there are a lot of users in the system. +user_change_homespace_info=Selecting a new home space for a user will not remove the existing permissions on the original home space. You may wish to use the Manage Space Users dialog to modify permissions if they are no longer required on the original home space. # Content Wizard messages add_content_dialog_title=Add Content Dialog diff --git a/source/java/org/alfresco/web/bean/clipboard/ClipboardBean.java b/source/java/org/alfresco/web/bean/clipboard/ClipboardBean.java index 7471bd3ba2..89c9b0c81f 100644 --- a/source/java/org/alfresco/web/bean/clipboard/ClipboardBean.java +++ b/source/java/org/alfresco/web/bean/clipboard/ClipboardBean.java @@ -28,6 +28,9 @@ import javax.faces.event.ActionEvent; import javax.transaction.UserTransaction; import org.alfresco.model.ContentModel; +import org.alfresco.repo.search.QueryParameterDefImpl; +import org.alfresco.service.ServiceRegistry; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.model.FileExistsException; import org.alfresco.service.cmr.model.FileFolderService; @@ -38,6 +41,8 @@ import org.alfresco.service.cmr.repository.CopyService; import org.alfresco.service.cmr.repository.InvalidNodeRefException; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.search.QueryParameterDefinition; +import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.namespace.QName; import org.alfresco.web.app.Application; import org.alfresco.web.app.context.UIContextService; @@ -81,6 +86,14 @@ public class ClipboardBean this.copyService = copyService; } + /** + * @param searchService The SearchService to set. + */ + public void setSearchService(SearchService searchService) + { + this.searchService = searchService; + } + /** * @param navigator The NavigationBean to set. */ @@ -244,6 +257,12 @@ public class ClipboardBean // initial name to attempt the copy of the item with String name = item.Node.getName(); + if (action == UIClipboardShelfItem.ACTION_PASTE_LINK) + { + // copy as link was specifically requested by the user + String linkTo = Application.getMessage(FacesContext.getCurrentInstance(), MSG_LINK_TO); + name = linkTo + ' ' + name; + } boolean operationComplete = false; while (operationComplete == false) @@ -254,56 +273,58 @@ public class ClipboardBean { if (action == UIClipboardShelfItem.ACTION_PASTE_LINK) { + // LINK operation if (logger.isDebugEnabled()) logger.debug("Attempting to link node ID: " + item.Node.getId() + " into node ID: " + destRef.getId()); - // copy as link was specifically requested by the user - // we create a special Link Object node that has a property to reference the original - // use FileFolderService to check if already exists as using nodeService directly here - String linkTo = Application.getMessage(FacesContext.getCurrentInstance(), MSG_LINK_TO); - // create the node using the nodeService (can only use FileFolderService for content) - Map props = new HashMap(4, 1.0f); - String linkName = linkTo + ' ' + name; - props.put(ContentModel.PROP_NAME, linkName + ".lnk"); - props.put(ContentModel.PROP_LINK_DESTINATION, item.Node.getNodeRef()); - if (dd.isSubClass(item.Node.getType(), ContentModel.TYPE_CONTENT)) + if (checkExists(name + ".lnk", destRef) == false) { - // create File Link node - ChildAssociationRef childRef = this.nodeService.createNode( - destRef, - ContentModel.ASSOC_CONTAINS, - assocRef.getQName(), - ContentModel.TYPE_FILELINK, - props); + Map props = new HashMap(2, 1.0f); + props.put(ContentModel.PROP_NAME, name + ".lnk"); + props.put(ContentModel.PROP_LINK_DESTINATION, item.Node.getNodeRef()); + if (dd.isSubClass(item.Node.getType(), ContentModel.TYPE_CONTENT)) + { + // create File Link node + ChildAssociationRef childRef = this.nodeService.createNode( + destRef, + ContentModel.ASSOC_CONTAINS, + assocRef.getQName(), + ContentModel.TYPE_FILELINK, + props); + + // apply the titled aspect - title and description + Map titledProps = new HashMap(2, 1.0f); + titledProps.put(ContentModel.PROP_TITLE, name); + titledProps.put(ContentModel.PROP_DESCRIPTION, name); + this.nodeService.addAspect(childRef.getChildRef(), ContentModel.ASPECT_TITLED, titledProps); + } + else + { + // create Folder link node + ChildAssociationRef childRef = this.nodeService.createNode( + destRef, + ContentModel.ASSOC_CONTAINS, + assocRef.getQName(), + ContentModel.TYPE_FOLDERLINK, + props); + + // apply the uifacets aspect - icon, title and description props + Map uiFacetsProps = new HashMap(4, 1.0f); + uiFacetsProps.put(ContentModel.PROP_ICON, "space-icon-link"); + uiFacetsProps.put(ContentModel.PROP_TITLE, name); + uiFacetsProps.put(ContentModel.PROP_DESCRIPTION, name); + this.nodeService.addAspect(childRef.getChildRef(), ContentModel.ASPECT_UIFACETS, uiFacetsProps); + } - // apply the titled aspect - title and description - Map titledProps = new HashMap(2, 1.0f); - titledProps.put(ContentModel.PROP_TITLE, linkName); - titledProps.put(ContentModel.PROP_DESCRIPTION, linkName); - this.nodeService.addAspect(childRef.getChildRef(), ContentModel.ASPECT_TITLED, titledProps); - } - else - { - // create Folder link node - ChildAssociationRef childRef = this.nodeService.createNode( - destRef, - ContentModel.ASSOC_CONTAINS, - assocRef.getQName(), - ContentModel.TYPE_FOLDERLINK, - props); - - // apply the uifacets aspect - icon, title and description props - Map uiFacetsProps = new HashMap(3, 1.0f); - uiFacetsProps.put(ContentModel.PROP_ICON, "space-icon-link"); - uiFacetsProps.put(ContentModel.PROP_TITLE, linkName); - uiFacetsProps.put(ContentModel.PROP_DESCRIPTION, linkName); - this.nodeService.addAspect(childRef.getChildRef(), ContentModel.ASPECT_UIFACETS, uiFacetsProps); + // if we get here without an exception, the clipboard link operation was successful + operationComplete = true; } } else { + // COPY operation if (logger.isDebugEnabled()) logger.debug("Attempting to copy node ID: " + item.Node.getId() + " into node ID: " + destRef.getId()); @@ -326,17 +347,24 @@ public class ClipboardBean else { // copy the node - this.copyService.copy( - item.Node.getNodeRef(), - destRef, - ContentModel.ASSOC_CONTAINS, - assocRef.getQName(), - true); + if (checkExists(name, destRef) == false) + { + this.copyService.copy( + item.Node.getNodeRef(), + destRef, + ContentModel.ASSOC_CONTAINS, + assocRef.getQName(), + true); + } } + + // if we get here without an exception, the clipboard copy operation was successful + operationComplete = true; } } else { + // MOVE operation if (logger.isDebugEnabled()) logger.debug("Attempting to move node ID: " + item.Node.getId() + " into node ID: " + destRef.getId()); @@ -358,27 +386,57 @@ public class ClipboardBean ContentModel.ASSOC_CONTAINS, assocRef.getQName()); } + + // if we get here without an exception, the clipboard move operation was successful + operationComplete = true; } - - // if we get here without an exception, the clipboard operation was successful - operationComplete = true; } catch (FileExistsException fileExistsErr) { - if (item.Mode == ClipboardStatus.COPY) + if (item.Mode != ClipboardStatus.COPY) { - String copyOf = Application.getMessage(FacesContext.getCurrentInstance(), MSG_COPY_OF); - name = copyOf + ' ' + name; - } - else - { - // we should not rename an item when it is being moved + // we should not rename an item when it is being moved - so exit throw fileExistsErr; } } + if (operationComplete == false) + { + String copyOf = Application.getMessage(FacesContext.getCurrentInstance(), MSG_COPY_OF); + name = copyOf + ' ' + name; + } } } + private boolean checkExists(String name, NodeRef parent) + { + ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance()); + + QueryParameterDefinition[] params = new QueryParameterDefinition[1]; + params[0] = new QueryParameterDefImpl( + ContentModel.PROP_NAME, + services.getDictionaryService().getDataType( + DataTypeDefinition.TEXT), + true, + name); + + // execute the query + List nodeRefs = searchService.selectNodes( + parent, + XPATH_QUERY_NODE_MATCH, + params, + services.getNamespaceService(), + false); + + return (nodeRefs.size() != 0); + } + + /** Shallow search for nodes with a name pattern */ + private static final String XPATH_QUERY_NODE_MATCH = + "./*" + + "[like(@cm:name, $cm:name, false)]";// + + //" and not (subtypeOf('" + ContentModel.TYPE_SYSTEM_FOLDER + "'))" + + //" and (subtypeOf('" + ContentModel.TYPE_FOLDER + "') or subtypeOf('" + ContentModel.TYPE_CONTENT + "'))]"; + /** * Add a clipboard node for an operation to the clipboard * @@ -437,6 +495,9 @@ public class ClipboardBean /** The CopyService to be used by the bean */ protected CopyService copyService; + /** The SearchService to be used by the bean */ + protected SearchService searchService; + /** The NavigationBean reference */ protected NavigationBean navigator; diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 296811df9b..0ffa55a54e 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -239,6 +239,10 @@ copyService #{CopyService} + + searchService + #{SearchService} + diff --git a/source/web/jsp/wizard/new-user/user-properties.jsp b/source/web/jsp/wizard/new-user/user-properties.jsp index 096caa1a15..b26bdef311 100644 --- a/source/web/jsp/wizard/new-user/user-properties.jsp +++ b/source/web/jsp/wizard/new-user/user-properties.jsp @@ -205,6 +205,23 @@ + + + + <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "yellowInner", "#ffffcc"); %> + + + + + +
+ +
+ <% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "yellowInner"); %> + + +
+