mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
. "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:
@@ -16,10 +16,14 @@
|
||||
*/
|
||||
package org.alfresco.web.action.evaluator;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.action.ActionEvaluator;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Checkout document.
|
||||
@@ -33,9 +37,13 @@ public final class CheckoutDocEvaluator implements ActionEvaluator
|
||||
*/
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
return (node.hasPermission(PermissionService.CHECK_OUT) &&
|
||||
DictionaryService dd = Repository.getServiceRegistry(
|
||||
FacesContext.getCurrentInstance()).getDictionaryService();
|
||||
|
||||
return dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT) &&
|
||||
((node.hasPermission(PermissionService.CHECK_OUT) &&
|
||||
(node.isLocked() == false &&
|
||||
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false));
|
||||
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false)));
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
@@ -19,9 +19,11 @@ package org.alfresco.web.action.evaluator;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.web.action.ActionEvaluator;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Edit document via CIFS.
|
||||
@@ -36,19 +38,25 @@ public final class EditDocCIFSEvaluator implements ActionEvaluator
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
|
||||
|
||||
boolean result = false;
|
||||
|
||||
// if the node is inline editable, the default http behaviour should always be used
|
||||
if (node.hasAspect(ContentModel.ASPECT_INLINEEDITABLE) == false &&
|
||||
"webdav".equals(Application.getClientConfig(fc).getEditLinkType()))
|
||||
if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
if (node.isWorkingCopyOwner() == true ||
|
||||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
|
||||
if (node.hasAspect(ContentModel.ASPECT_INLINEEDITABLE) == false &&
|
||||
"webdav".equals(Application.getClientConfig(fc).getEditLinkType()))
|
||||
{
|
||||
return true;
|
||||
if (node.isWorkingCopyOwner() == true ||
|
||||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
@@ -19,9 +19,11 @@ package org.alfresco.web.action.evaluator;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.web.action.ActionEvaluator;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Edit document via HTTP or inline edit.
|
||||
@@ -36,20 +38,26 @@ public final class EditDocHttpEvaluator implements ActionEvaluator
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
|
||||
|
||||
boolean result = false;
|
||||
|
||||
// if the node is inline editable, the default http behaviour should
|
||||
// always be used otherwise the configured approach is used
|
||||
if (node.hasAspect(ContentModel.ASPECT_INLINEEDITABLE) == true ||
|
||||
"http".equals(Application.getClientConfig(fc).getEditLinkType()))
|
||||
if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
if (node.isWorkingCopyOwner() == true ||
|
||||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
|
||||
if (node.hasAspect(ContentModel.ASPECT_INLINEEDITABLE) == true ||
|
||||
"http".equals(Application.getClientConfig(fc).getEditLinkType()))
|
||||
{
|
||||
return true;
|
||||
if (node.isWorkingCopyOwner() == true ||
|
||||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
@@ -19,9 +19,11 @@ package org.alfresco.web.action.evaluator;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.web.action.ActionEvaluator;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Edit document via Webdav.
|
||||
@@ -36,19 +38,25 @@ public final class EditDocWebDavEvaluator implements ActionEvaluator
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
|
||||
|
||||
boolean result = false;
|
||||
|
||||
// if the node is inline editable, the default http behaviour should always be used
|
||||
if (node.hasAspect(ContentModel.ASPECT_INLINEEDITABLE) == false &&
|
||||
"cifs".equals(Application.getClientConfig(fc).getEditLinkType()))
|
||||
if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
if (node.isWorkingCopyOwner() == true ||
|
||||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
|
||||
if (node.hasAspect(ContentModel.ASPECT_INLINEEDITABLE) == false &&
|
||||
"cifs".equals(Application.getClientConfig(fc).getEditLinkType()))
|
||||
{
|
||||
return true;
|
||||
if (node.isWorkingCopyOwner() == true ||
|
||||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
@@ -16,9 +16,13 @@
|
||||
*/
|
||||
package org.alfresco.web.action.evaluator;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.web.action.ActionEvaluator;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Update document content.
|
||||
@@ -32,9 +36,13 @@ public final class UpdateDocEvaluator implements ActionEvaluator
|
||||
*/
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
return (node.isWorkingCopyOwner() == true ||
|
||||
DictionaryService dd = Repository.getServiceRegistry(
|
||||
FacesContext.getCurrentInstance()).getDictionaryService();
|
||||
|
||||
return dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT) &&
|
||||
((node.isWorkingCopyOwner() == true ||
|
||||
(node.isLocked() == false &&
|
||||
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false));
|
||||
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false)));
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
@@ -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);
|
||||
|
@@ -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(),
|
||||
|
263
source/java/org/alfresco/web/bean/LinkPropertiesBean.java
Normal file
263
source/java/org/alfresco/web/bean/LinkPropertiesBean.java
Normal 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;
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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++)
|
||||
|
@@ -523,12 +523,14 @@ public final class Utils
|
||||
* The supported values for the usage parameter are of URLMode enum type
|
||||
* @see URLMode
|
||||
*
|
||||
* @param context Faces context
|
||||
* @param node The node to generate the URL for
|
||||
* @param usage What the URL is going to be used for
|
||||
* @param context Faces context
|
||||
* @param node The node to generate the URL for
|
||||
* @param name Name to use for the download file part of the link if any
|
||||
* @param usage What the URL is going to be used for
|
||||
*
|
||||
* @return The URL for the requested usage without the context path
|
||||
*/
|
||||
public static String generateURL(FacesContext context, Node node, URLMode usage)
|
||||
public static String generateURL(FacesContext context, Node node, String name, URLMode usage)
|
||||
{
|
||||
String url = null;
|
||||
|
||||
@@ -612,13 +614,13 @@ public final class Utils
|
||||
|
||||
case HTTP_DOWNLOAD:
|
||||
{
|
||||
url = DownloadContentServlet.generateDownloadURL(node.getNodeRef(), node.getName());
|
||||
url = DownloadContentServlet.generateDownloadURL(node.getNodeRef(), name);
|
||||
break;
|
||||
}
|
||||
|
||||
case HTTP_INLINE:
|
||||
{
|
||||
url = DownloadContentServlet.generateBrowserURL(node.getNodeRef(), node.getName());
|
||||
url = DownloadContentServlet.generateBrowserURL(node.getNodeRef(), name);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -652,6 +654,23 @@ public final class Utils
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a URL for the given usage for the given node.
|
||||
*
|
||||
* The supported values for the usage parameter are of URLMode enum type
|
||||
* @see URLMode
|
||||
*
|
||||
* @param context Faces context
|
||||
* @param node The node to generate the URL for
|
||||
* @param usage What the URL is going to be used for
|
||||
*
|
||||
* @return The URL for the requested usage without the context path
|
||||
*/
|
||||
public static String generateURL(FacesContext context, Node node, URLMode usage)
|
||||
{
|
||||
return generateURL(context, node, node.getName(), usage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a context path safe image tag for the supplied image path.
|
||||
* Image path should be supplied with a leading slash '/'.
|
||||
@@ -665,7 +684,8 @@ public final class Utils
|
||||
*
|
||||
* @return Populated <code>img</code> tag
|
||||
*/
|
||||
public static String buildImageTag(FacesContext context, String image, int width, int height, String alt, String onclick)
|
||||
public static String buildImageTag(FacesContext context, String image, int width, int height,
|
||||
String alt, String onclick)
|
||||
{
|
||||
return buildImageTag(context, image, width, height, alt, onclick, null);
|
||||
}
|
||||
@@ -684,7 +704,8 @@ public final class Utils
|
||||
*
|
||||
* @return Populated <code>img</code> tag
|
||||
*/
|
||||
public static String buildImageTag(FacesContext context, String image, int width, int height, String alt, String onclick, String align)
|
||||
public static String buildImageTag(FacesContext context, String image, int width, int height,
|
||||
String alt, String onclick, String align)
|
||||
{
|
||||
StringBuilder buf = new StringBuilder(200);
|
||||
|
||||
|
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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.ui.common.converter;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.convert.Converter;
|
||||
import javax.faces.convert.ConverterException;
|
||||
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
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.repository.Path;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* Converter class to convert a Path or NodeRef reference value (including null) into a human readable form.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class DisplayPathConverter implements Converter
|
||||
{
|
||||
/**
|
||||
* <p>The standard converter id for this converter.</p>
|
||||
*/
|
||||
public static final String CONVERTER_ID = "org.alfresco.faces.DisplayPathConverter";
|
||||
|
||||
/**
|
||||
* @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
|
||||
*/
|
||||
public Object getAsObject(FacesContext context, UIComponent component, String value)
|
||||
throws ConverterException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
|
||||
*/
|
||||
public String getAsString(FacesContext context, UIComponent component, Object value)
|
||||
throws ConverterException
|
||||
{
|
||||
String result = "";
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
|
||||
Path path = null;
|
||||
if (value instanceof NodeRef)
|
||||
{
|
||||
path = nodeService.getPath((NodeRef)value);
|
||||
}
|
||||
else if (value instanceof Path)
|
||||
{
|
||||
path = (Path)value;
|
||||
}
|
||||
if (path != null)
|
||||
{
|
||||
result = Repository.getNamePath(nodeService, path, null, "/", null);
|
||||
}
|
||||
}
|
||||
catch (AccessDeniedException accessErr)
|
||||
{
|
||||
// use default if this occurs
|
||||
}
|
||||
catch (InvalidNodeRefException nodeErr)
|
||||
{
|
||||
// use default if this occurs
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -30,6 +30,7 @@ public class WebResources extends org.alfresco.web.ui.common.WebResources
|
||||
public static final String IMAGE_COPY = "/images/icons/copy.gif";
|
||||
public static final String IMAGE_CUT = "/images/icons/cut.gif";
|
||||
public static final String IMAGE_PASTE = "/images/icons/paste.gif";
|
||||
public static final String IMAGE_PASTE_LINK = "/images/icons/paste_link.gif";
|
||||
public static final String IMAGE_LOCK = "/images/icons/locked.gif";
|
||||
public static final String IMAGE_LOCK_OWNER = "/images/icons/locked_owner.gif";
|
||||
public static final String IMAGE_PERSON = "/images/icons/person.gif";
|
||||
|
@@ -184,7 +184,7 @@ public class UIClipboardShelfItem extends UIShelfItem
|
||||
}
|
||||
out.write(Utils.buildImageTag(context, icon, 16, 16, null, null, "absmiddle"));
|
||||
}
|
||||
else if (dd.isSubClass(item.Node.getType(), ContentModel.TYPE_CONTENT))
|
||||
else
|
||||
{
|
||||
String image = Utils.getFileTypeImage(item.Node.getName(), true);
|
||||
out.write(Utils.buildImageTag(context, image, null, "absmiddle"));
|
||||
@@ -200,11 +200,11 @@ public class UIClipboardShelfItem extends UIShelfItem
|
||||
out.write(buildActionLink(ACTION_REMOVE_ITEM, i, bundle.getString(MSG_REMOVE_ITEM), WebResources.IMAGE_REMOVE));
|
||||
out.write(" ");
|
||||
out.write(buildActionLink(ACTION_PASTE_ITEM, i, bundle.getString(MSG_PASTE_ITEM), WebResources.IMAGE_PASTE));
|
||||
//if (item.Mode == ClipboardStatus.COPY)
|
||||
//{
|
||||
// out.write(" ");
|
||||
// out.write(buildActionLink(ACTION_PASTE_LINK, i, bundle.getString(MSG_PASTE_LINK), WebResources.IMAGE_PASTE_LINK));
|
||||
//}
|
||||
if (item.Mode == ClipboardStatus.COPY)
|
||||
{
|
||||
out.write(" ");
|
||||
out.write(buildActionLink(ACTION_PASTE_LINK, i, bundle.getString(MSG_PASTE_LINK), WebResources.IMAGE_PASTE_LINK));
|
||||
}
|
||||
|
||||
// end actions cell and end row
|
||||
out.write("</nobr></td></tr>");
|
||||
|
Reference in New Issue
Block a user