. "Paste As Link" and link object support in the web-client:

. Filetype icons for PSD (Photoshop) file-format
. Import, Export and Manage Space Users actions added to Forums details page
. Manage Space Users action added to Forum and Topic details pages
. Removed some obsolete JSF navigation outcomes from dialogs/faces-config
. Approx 10% performance improvement when showing large search results pages

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2582 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-03-27 15:46:20 +00:00
parent 9be6273144
commit 8187b27ecf
41 changed files with 1578 additions and 199 deletions

View File

@@ -424,11 +424,11 @@ public class BrowseBean implements IContextListener
{
// special properties to be used by the value binding components on the page
node.addPropertyResolver("url", this.resolverUrl);
node.addPropertyResolver("webdavUrl", this.resolverWebdavUrl);
node.addPropertyResolver("cifsPath", this.resolverCifsPath);
node.addPropertyResolver("fileType16", this.resolverFileType16);
node.addPropertyResolver("fileType32", this.resolverFileType32);
node.addPropertyResolver("size", this.resolverSize);
node.addPropertyResolver("webdavUrl", this.resolverWebdavUrl);
node.addPropertyResolver("cifsPath", this.resolverCifsPath);
}
@@ -557,35 +557,59 @@ public class BrowseBean implements IContextListener
if (typeDef != null)
{
// look for Space or File nodes
MapNode node = null;
// look for Space folder node
if (this.dictionaryService.isSubClass(type, ContentModel.TYPE_FOLDER) == true &&
this.dictionaryService.isSubClass(type, ContentModel.TYPE_SYSTEM_FOLDER) == false)
{
// create our Node representation
MapNode node = new MapNode(nodeRef, this.nodeService, true);
node = new MapNode(nodeRef, this.nodeService, false);
node.addPropertyResolver("icon", this.resolverSpaceIcon);
node.addPropertyResolver("smallIcon", this.resolverSmallIcon);
for (NodeEventListener listener : getNodeEventListeners())
{
listener.created(node, type);
}
this.containerNodes.add(node);
}
// look for File content node
else if (this.dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT))
{
// create our Node representation
MapNode node = new MapNode(nodeRef, this.nodeService, true);
node = new MapNode(nodeRef, this.nodeService, false);
setupCommonBindingProperties(node);
this.contentNodes.add(node);
}
// look for File Link object node
else if (ContentModel.TYPE_FILELINK.equals(type))
{
// create our File Link Node representation
node = new MapNode(nodeRef, this.nodeService, false);
node.addPropertyResolver("url", this.resolverLinkUrl);
node.addPropertyResolver("webdavUrl", this.resolverLinkWebdavUrl);
node.addPropertyResolver("cifsPath", this.resolverLinkCifsPath);
node.addPropertyResolver("fileType16", this.resolverFileType16);
node.addPropertyResolver("fileType32", this.resolverFileType32);
node.addPropertyResolver("size", this.resolverSize);
this.contentNodes.add(node);
}
else if (ContentModel.TYPE_FOLDERLINK.equals(type))
{
// create our Folder Link Node representation
node = new MapNode(nodeRef, this.nodeService, false);
node.addPropertyResolver("icon", this.resolverSpaceIcon);
node.addPropertyResolver("smallIcon", this.resolverSmallIcon);
this.containerNodes.add(node);
}
// inform any listeners that a Node wrapper has been created
if (node != null)
{
for (NodeEventListener listener : getNodeEventListeners())
{
listener.created(node, type);
}
this.contentNodes.add(node);
}
}
else
@@ -680,41 +704,69 @@ public class BrowseBean implements IContextListener
if (typeDef != null)
{
MapNode node = null;
// look for Space or File nodes
if (this.dictionaryService.isSubClass(type, ContentModel.TYPE_FOLDER) &&
this.dictionaryService.isSubClass(type, ContentModel.TYPE_SYSTEM_FOLDER) == false)
{
// create our Node representation
MapNode node = new MapNode(nodeRef, this.nodeService, true);
node = new MapNode(nodeRef, this.nodeService, false);
node.addPropertyResolver("path", this.resolverPath);
node.addPropertyResolver("displayPath", this.resolverDisplayPath);
node.addPropertyResolver("icon", this.resolverSpaceIcon);
node.addPropertyResolver("smallIcon", this.resolverSmallIcon);
for (NodeEventListener listener : getNodeEventListeners())
{
listener.created(node, type);
}
this.containerNodes.add(node);
}
else if (this.dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT))
{
// create our Node representation
MapNode node = new MapNode(nodeRef, this.nodeService, true);
node = new MapNode(nodeRef, this.nodeService, false);
setupCommonBindingProperties(node);
node.addPropertyResolver("path", this.resolverPath);
node.addPropertyResolver("displayPath", this.resolverDisplayPath);
this.contentNodes.add(node);
}
// look for File Link object node
else if (ContentModel.TYPE_FILELINK.equals(type))
{
// create our File Link Node representation
node = new MapNode(nodeRef, this.nodeService, false);
node.addPropertyResolver("url", this.resolverLinkUrl);
node.addPropertyResolver("webdavUrl", this.resolverLinkWebdavUrl);
node.addPropertyResolver("cifsPath", this.resolverLinkCifsPath);
node.addPropertyResolver("fileType16", this.resolverFileType16);
node.addPropertyResolver("fileType32", this.resolverFileType32);
node.addPropertyResolver("size", this.resolverSize);
node.addPropertyResolver("path", this.resolverPath);
node.addPropertyResolver("displayPath", this.resolverDisplayPath);
this.contentNodes.add(node);
}
else if (ContentModel.TYPE_FOLDERLINK.equals(type))
{
// create our Folder Link Node representation
node = new MapNode(nodeRef, this.nodeService, false);
node.addPropertyResolver("icon", this.resolverSpaceIcon);
node.addPropertyResolver("smallIcon", this.resolverSmallIcon);
node.addPropertyResolver("path", this.resolverPath);
node.addPropertyResolver("displayPath", this.resolverDisplayPath);
this.containerNodes.add(node);
}
// inform any listeners that a Node wrapper has been created
if (node != null)
{
for (NodeEventListener listener : getNodeEventListeners())
{
listener.created(node, type);
}
this.contentNodes.add(node);
}
}
else
@@ -794,6 +846,36 @@ public class BrowseBean implements IContextListener
}
};
public NodePropertyResolver resolverLinkDownload = new NodePropertyResolver() {
public Object get(Node node) {
NodeRef destRef = (NodeRef)node.getProperties().get(ContentModel.PROP_LINK_DESTINATION);
String destName = Repository.getNameForNode(nodeService, destRef);
return DownloadContentServlet.generateDownloadURL(node.getNodeRef(), destName);
}
};
public NodePropertyResolver resolverLinkUrl = new NodePropertyResolver() {
public Object get(Node node) {
NodeRef destRef = (NodeRef)node.getProperties().get(ContentModel.PROP_LINK_DESTINATION);
String destName = Repository.getNameForNode(nodeService, destRef);
return DownloadContentServlet.generateBrowserURL(destRef, destName);
}
};
public NodePropertyResolver resolverLinkWebdavUrl = new NodePropertyResolver() {
public Object get(Node node) {
NodeRef destRef = (NodeRef)node.getProperties().get(ContentModel.PROP_LINK_DESTINATION);
return Utils.generateURL(FacesContext.getCurrentInstance(), new Node(destRef), URLMode.WEBDAV);
}
};
public NodePropertyResolver resolverLinkCifsPath = new NodePropertyResolver() {
public Object get(Node node) {
NodeRef destRef = (NodeRef)node.getProperties().get(ContentModel.PROP_LINK_DESTINATION);
return Utils.generateURL(FacesContext.getCurrentInstance(), new Node(destRef), URLMode.CIFS);
}
};
public NodePropertyResolver resolverFileType16 = new NodePropertyResolver() {
public Object get(Node node) {
return Utils.getFileTypeImage(node.getName(), true);
@@ -845,7 +927,7 @@ public class BrowseBean implements IContextListener
public NodePropertyResolver resolverSize = new NodePropertyResolver() {
public Object get(Node node) {
ContentData content = (ContentData)node.getProperties().get(ContentModel.PROP_CONTENT);
return (content != null ? new Long(content.getSize()) : null);
return (content != null ? new Long(content.getSize()) : 0L);
}
};
@@ -889,6 +971,13 @@ public class BrowseBean implements IContextListener
try
{
NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
// handle special folder link node case
if (ContentModel.TYPE_FOLDERLINK.equals(this.nodeService.getType(ref)))
{
ref = (NodeRef)this.nodeService.getProperty(ref, ContentModel.PROP_LINK_DESTINATION);
}
clickSpace(ref);
}
catch (InvalidNodeRefException refErr)
@@ -1096,7 +1185,14 @@ public class BrowseBean implements IContextListener
Node node = new Node(ref);
// store the URL to for downloading the content
node.addPropertyResolver("url", this.resolverDownload);
if (ContentModel.TYPE_FILELINK.equals(node.getType()))
{
node.addPropertyResolver("url", this.resolverLinkDownload);
}
else
{
node.addPropertyResolver("url", this.resolverDownload);
}
node.addPropertyResolver("fileType32", this.resolverFileType32);
node.addPropertyResolver("mimetype", this.resolverMimetype);
node.addPropertyResolver("size", this.resolverSize);

View File

@@ -156,7 +156,8 @@ public class DocumentDetailsBean
*/
public String getBrowserUrl()
{
return Utils.generateURL(FacesContext.getCurrentInstance(), getDocument(), URLMode.HTTP_INLINE);
Node doc = getLinkResolvedDocument();
return Utils.generateURL(FacesContext.getCurrentInstance(), doc, URLMode.HTTP_INLINE);
}
/**
@@ -166,7 +167,8 @@ public class DocumentDetailsBean
*/
public String getDownloadUrl()
{
return Utils.generateURL(FacesContext.getCurrentInstance(), getDocument(), URLMode.HTTP_DOWNLOAD);
Node doc = getLinkResolvedDocument();
return Utils.generateURL(FacesContext.getCurrentInstance(), doc, URLMode.HTTP_DOWNLOAD);
}
/**
@@ -176,7 +178,19 @@ public class DocumentDetailsBean
*/
public String getWebdavUrl()
{
return Utils.generateURL(FacesContext.getCurrentInstance(), getDocument(), URLMode.WEBDAV);
Node doc = getLinkResolvedDocument();
return Utils.generateURL(FacesContext.getCurrentInstance(), doc, URLMode.WEBDAV);
}
/**
* Returns the CIFS path for the current document
*
* @return The CIFS path
*/
public String getCifsPath()
{
Node doc = getLinkResolvedDocument();
return Utils.generateURL(FacesContext.getCurrentInstance(), doc, URLMode.CIFS);
}
/**
@@ -190,13 +204,19 @@ public class DocumentDetailsBean
}
/**
* Returns the CIFS path for the current document
* Resolve the actual document Node from any Link object that may be proxying it
*
* @return The CIFS path
* @return current document Node or document Node resolved from any Link object
*/
public String getCifsPath()
private Node getLinkResolvedDocument()
{
return Utils.generateURL(FacesContext.getCurrentInstance(), getDocument(), URLMode.CIFS);
Node document = getDocument();
if (ContentModel.TYPE_FILELINK.equals(document.getType()))
{
NodeRef destRef = (NodeRef)document.getProperties().get(ContentModel.PROP_LINK_DESTINATION);
document = new Node(destRef);
}
return document;
}
/**
@@ -1075,19 +1095,21 @@ public class DocumentDetailsBean
*/
public void takeOwnership(ActionEvent event)
{
FacesContext fc = FacesContext.getCurrentInstance();
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
tx = Repository.getUserTransaction(fc);
tx.begin();
this.ownableService.takeOwnership(getDocument().getNodeRef());
FacesContext context = FacesContext.getCurrentInstance();
String msg = Application.getMessage(context, MSG_SUCCESS_OWNERSHIP);
String msg = Application.getMessage(fc, MSG_SUCCESS_OWNERSHIP);
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
context.addMessage("document-details:document-props", facesMsg);
String formId = Utils.getParentForm(fc, event.getComponent()).getClientId(fc);
fc.addMessage(formId + ":document-props", facesMsg);
// commit the transaction
tx.commit();
@@ -1097,7 +1119,7 @@ public class DocumentDetailsBean
// rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
fc, Repository.ERROR_GENERIC), e.getMessage()), e);
}
}
@@ -1125,7 +1147,7 @@ public class DocumentDetailsBean
*/
public Map getTemplateModel()
{
HashMap model = new HashMap(3, 1.0f);
HashMap model = new HashMap(2, 1.0f);
FacesContext fc = FacesContext.getCurrentInstance();
TemplateNode documentNode = new TemplateNode(getDocument().getNodeRef(),

View File

@@ -0,0 +1,263 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.bean;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
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.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
/**
* Backing bean for the edit link properties dialog
*
* @author kevinr
*/
public class LinkPropertiesBean
{
protected NodeService nodeService;
protected DictionaryService dictionaryService;
protected BrowseBean browseBean;
protected NavigationBean navigator;
private Node editableNode;
/**
* Returns the node being edited
*
* @return The node being edited
*/
public Node getEditableNode()
{
return this.editableNode;
}
/**
* Event handler called to setup the link object for property editing
*
* @param event The event
*/
public void setupFileLinkForAction(ActionEvent event)
{
this.editableNode = new Node(this.browseBean.getDocument().getNodeRef());
}
/**
* Event handler called to setup the link object for property editing
*
* @param event The event
*/
public void setupFolderLinkForAction(ActionEvent event)
{
this.editableNode = new Node(this.browseBean.getActionSpace().getNodeRef());
}
/**
* @return Human readable version of the Path to the destination object
*/
public String getDestinationPath()
{
NodeRef destRef = (NodeRef)this.editableNode.getProperties().get(ContentModel.PROP_LINK_DESTINATION);
return Repository.getNamePath(
this.nodeService, this.nodeService.getPath(destRef), null, "/", null);
}
/**
* Event handler used to save the edited properties back to the repository
*
* @return The outcome
*/
public String save()
{
String outcome = "cancelEdit";
// setup the dispatch context as it is required for correct cancel/finish back to link dialog
this.navigator.setupDispatchContext(this.editableNode);
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
tx.begin();
NodeRef nodeRef = this.editableNode.getNodeRef();
Map<String, Object> props = this.editableNode.getProperties();
// get the name and move the node as necessary
String name = (String)props.get(ContentModel.PROP_NAME);
//if (name != null)
//{
// fileFolderService.rename(nodeRef, name);
//}
Map<QName, Serializable> properties = this.nodeService.getProperties(nodeRef);
// we need to put all the properties from the editable bag back into
// the format expected by the repository
// deal with adding the "titled" aspect if required
String title = (String)props.get(ContentModel.PROP_TITLE);
String description = (String)props.get(ContentModel.PROP_DESCRIPTION);
if (title != null || description != null)
{
// add the aspect to be sure it's present
nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, null);
// other props will get added later in setProperties()
}
// add the remaining properties
Iterator<String> iterProps = props.keySet().iterator();
while (iterProps.hasNext())
{
String propName = iterProps.next();
QName qname = QName.createQName(propName);
// make sure the property is represented correctly
Serializable propValue = (Serializable)props.get(propName);
// check for empty strings when using number types, set to null in this case
if ((propValue != null) && (propValue instanceof String) &&
(propValue.toString().length() == 0))
{
PropertyDefinition propDef = this.dictionaryService.getProperty(qname);
if (propDef != null)
{
if (propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE) ||
propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT) ||
propDef.getDataType().getName().equals(DataTypeDefinition.INT) ||
propDef.getDataType().getName().equals(DataTypeDefinition.LONG))
{
propValue = null;
}
}
}
properties.put(qname, propValue);
}
// send the properties back to the repository
this.nodeService.setProperties(nodeRef, properties);
// commit the transaction
tx.commit();
// set the outcome to refresh
outcome = "finishEdit";
// reset any document held by the browse bean as it's just been updated
// if this is a space link then it doesn't matter anyway
this.browseBean.getDocument().reset();
}
catch (InvalidNodeRefException err)
{
// rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] {this.browseBean.getDocument().getId()}) );
// this failure means the node no longer exists - we cannot show the doc properties screen
outcome = "browse";
}
catch (Throwable e)
{
// rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
}
return outcome;
}
public String cancel()
{
// setup the dispatch context as it is required for correct cancel/finish back to link dialog
this.navigator.setupDispatchContext(this.editableNode);
return "cancelEdit";
}
public Map<String, Object> getProperties()
{
return this.editableNode.getProperties();
}
/**
* @return Returns the nodeService.
*/
public NodeService getNodeService()
{
return this.nodeService;
}
/**
* @param nodeService The nodeService to set.
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* Sets the DictionaryService to use when persisting metadata
*
* @param dictionaryService The DictionaryService
*/
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
/**
* @return The BrowseBean
*/
public BrowseBean getBrowseBean()
{
return this.browseBean;
}
/**
* @param browseBean The BrowseBean to set.
*/
public void setBrowseBean(BrowseBean browseBean)
{
this.browseBean = browseBean;
}
/**
* @param navigator The NavigationBean to set.
*/
public void setNavigator(NavigationBean navigator)
{
this.navigator = navigator;
}
}

View File

@@ -155,7 +155,19 @@ public class SpaceDetailsBean
*/
public String getWebdavUrl()
{
return Utils.generateURL(FacesContext.getCurrentInstance(), getSpace(), URLMode.WEBDAV);
Node space = getLinkResolvedSpace();
return Utils.generateURL(FacesContext.getCurrentInstance(), space, URLMode.WEBDAV);
}
/**
* Returns the CIFS path for the current space
*
* @return The CIFS path
*/
public String getCifsPath()
{
Node space = getLinkResolvedSpace();
return Utils.generateURL(FacesContext.getCurrentInstance(), space, URLMode.CIFS);
}
/**
@@ -169,13 +181,19 @@ public class SpaceDetailsBean
}
/**
* Returns the CIFS path for the current space
* Resolve the actual space Node from any Link object that may be proxying it
*
* @return The CIFS path
* @return current space Node or space Node resolved from any Link object
*/
public String getCifsPath()
private Node getLinkResolvedSpace()
{
return Utils.generateURL(FacesContext.getCurrentInstance(), getSpace(), URLMode.CIFS);
Node space = getSpace();
if (ContentModel.TYPE_FOLDERLINK.equals(space.getType()))
{
NodeRef destRef = (NodeRef)space.getProperties().get(ContentModel.PROP_LINK_DESTINATION);
space = new Node(destRef);
}
return space;
}
/**
@@ -312,20 +330,22 @@ public class SpaceDetailsBean
*/
public void takeOwnership(ActionEvent event)
{
FacesContext fc = FacesContext.getCurrentInstance();
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
tx = Repository.getUserTransaction(fc);
tx.begin();
this.ownableService.takeOwnership(getSpace().getNodeRef());
FacesContext context = FacesContext.getCurrentInstance();
String msg = Application.getMessage(context, MSG_SUCCESS_OWNERSHIP);
String msg = Application.getMessage(fc, MSG_SUCCESS_OWNERSHIP);
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
context.addMessage("space-details:space-props", facesMsg);
String formId = Utils.getParentForm(fc, event.getComponent()).getClientId(fc);
fc.addMessage(formId + ":space-props", facesMsg);
// commit the transaction
tx.commit();
}
@@ -334,7 +354,7 @@ public class SpaceDetailsBean
// rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
fc, Repository.ERROR_GENERIC), e.getMessage()), e);
}
}

View File

@@ -16,8 +16,10 @@
*/
package org.alfresco.web.bean.clipboard;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -26,13 +28,16 @@ import javax.faces.event.ActionEvent;
import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
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.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.UIContextService;
import org.alfresco.web.bean.NavigationBean;
@@ -67,6 +72,14 @@ public class ClipboardBean
this.fileFolderService = fileFolderService;
}
/**
* @param nodeOperationsService The NodeOperationsService to set.
*/
public void setNodeOperationsService(CopyService nodeOperationsService)
{
this.nodeOperationsService = nodeOperationsService;
}
/**
* @param navigator The NavigationBean to set.
*/
@@ -218,48 +231,132 @@ public class ClipboardBean
{
NodeRef destRef = new NodeRef(Repository.getStoreRef(), this.navigator.getCurrentNodeId());
// TODO: Should we use primary parent here?
DictionaryService dd = Repository.getServiceRegistry(
FacesContext.getCurrentInstance()).getDictionaryService();
// TODO: Should we be using primary parent here?
// We are assuming that the item exists in only a single parent and that the source for
// the clipboard operation (e.g. the source folder) is specifically that parent node.
// This does not allow for more than one possible parent node - or for linked objects!
// So does not allow for more than one possible parent node - or for linked objects!
// This code should be refactored to use a parent ID when appropriate.
ChildAssociationRef assocRef = this.nodeService.getPrimaryParent(item.Node.getNodeRef());
if (item.Mode == ClipboardStatus.COPY)
// initial name to attempt the copy of the item with
String name = item.Node.getName();
boolean operationComplete = false;
while (operationComplete == false)
{
if (action == UIClipboardShelfItem.ACTION_PASTE_LINK)
try
{
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
this.nodeService.addChild(
destRef,
item.Node.getNodeRef(),
ContentModel.ASSOC_CONTAINS,
assocRef.getQName());
}
else
{
if (logger.isDebugEnabled())
logger.debug("Attempting to copy node ID: " + item.Node.getId() + " into node ID: " + destRef.getId());
if (item.Mode == ClipboardStatus.COPY)
{
if (action == UIClipboardShelfItem.ACTION_PASTE_LINK)
{
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<QName, Serializable> props = new HashMap<QName, Serializable>(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))
{
// create File Link node
ChildAssociationRef childRef = this.nodeService.createNode(
destRef,
ContentModel.ASSOC_CONTAINS,
assocRef.getQName(),
ContentModel.TYPE_FILELINK,
props);
// call the node ops service to initiate the copy
this.fileFolderService.copy(
item.Node.getNodeRef(),
destRef,
null); // TODO: could add "Copy of ..." here if copy fails
// apply the titled aspect - title and description
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(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<QName, Serializable> uiFacetsProps = new HashMap<QName, Serializable>(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);
}
}
else
{
if (logger.isDebugEnabled())
logger.debug("Attempting to copy node ID: " + item.Node.getId() + " into node ID: " + destRef.getId());
if (dd.isSubClass(item.Node.getType(), ContentModel.TYPE_CONTENT))
{
// call the node ops service to initiate the copy
this.fileFolderService.copy(
item.Node.getNodeRef(),
destRef,
name);
}
else
{
this.nodeOperationsService.copy(
item.Node.getNodeRef(),
destRef,
ContentModel.ASSOC_CONTAINS,
assocRef.getQName(),
true);
}
}
}
else
{
if (logger.isDebugEnabled())
logger.debug("Attempting to move node ID: " + item.Node.getId() + " into node ID: " + destRef.getId());
if (dd.isSubClass(item.Node.getType(), ContentModel.TYPE_CONTENT))
{
// move the node
this.fileFolderService.move(
item.Node.getNodeRef(),
destRef,
name); // TODO: could add "Copy of ..." here if move fails
}
else
{
// move the node
this.nodeService.moveNode(
item.Node.getNodeRef(),
destRef,
ContentModel.ASSOC_CONTAINS,
assocRef.getQName());
}
}
// if we get here without an exception, the clipboard operation was successful
operationComplete = true;
}
catch (FileExistsException fileExistsErr)
{
String copyOf = Application.getMessage(FacesContext.getCurrentInstance(), MSG_COPY_OF);
name = copyOf + ' ' + name;
}
}
else
{
if (logger.isDebugEnabled())
logger.debug("Attempting to move node ID: " + item.Node.getId() + " into node ID: " + destRef.getId());
// move the node
this.fileFolderService.move(
item.Node.getNodeRef(),
destRef,
null); // TODO: could add "Copy of ..." here if move fails
}
}
@@ -308,7 +405,9 @@ public class ClipboardBean
private static Log logger = LogFactory.getLog(ClipboardBean.class);
/** I18N messages */
private static final String MSG_ERROR_PASTE = "error_paste";
private static final String MSG_ERROR_PASTE = "error_paste";
private static final String MSG_COPY_OF = "copy_of";
private static final String MSG_LINK_TO = "link_to";
/** The NodeService to be used by the bean */
protected NodeService nodeService;
@@ -316,6 +415,9 @@ public class ClipboardBean
/** The FileFolderService to be used by the bean */
protected FileFolderService fileFolderService;
/** The NodeOperationsService to be used by the bean */
protected CopyService nodeOperationsService;
/** The NavigationBean reference */
protected NavigationBean navigator;

View File

@@ -274,7 +274,10 @@ public final class Repository
// ignore root node check if not passed in
boolean foundRoot = (rootNode == null);
buf.append(prefix);
if (prefix != null)
{
buf.append(prefix);
}
// skip first element as it represents repo root '/'
for (int i=1; i<path.size(); i++)