mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,193 +1,193 @@
|
||||
package org.alfresco.web.bean.clipboard;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
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.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.search.QueryParameterDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Base class representing a single item added to the clipboard.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
abstract class AbstractClipboardItem implements ClipboardItem
|
||||
{
|
||||
protected static Log logger = LogFactory.getLog(ClipboardBean.class);
|
||||
|
||||
protected static final String MSG_COPY_OF = "copy_of";
|
||||
|
||||
/** Shallow search for nodes with a name pattern */
|
||||
private static final String XPATH_QUERY_NODE_MATCH = "./*[like(@cm:name, $cm:name, false)]";
|
||||
|
||||
transient private ServiceRegistry services = null;
|
||||
|
||||
protected NodeRef ref;
|
||||
protected NodeRef parent;
|
||||
protected ClipboardStatus mode;
|
||||
|
||||
// cached values
|
||||
private String name;
|
||||
private QName type;
|
||||
private String icon;
|
||||
|
||||
private List<String> customPasteViewIds;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ref The ref of the item on the clipboard
|
||||
* @param mode The ClipboardStatus enum value
|
||||
*/
|
||||
public AbstractClipboardItem(NodeRef ref, ClipboardStatus mode, List<String> customPasteViewIds)
|
||||
{
|
||||
this.ref = ref;
|
||||
this.mode = mode;
|
||||
this.customPasteViewIds = customPasteViewIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ref The ref of the item on the clipboard
|
||||
* @param parent The parent of the item on the clipboard
|
||||
* @param mode The ClipboardStatus enum value
|
||||
*/
|
||||
public AbstractClipboardItem(NodeRef ref, NodeRef parent, ClipboardStatus mode, List<String> customPasteViewIds)
|
||||
{
|
||||
this.ref = ref;
|
||||
this.mode = mode;
|
||||
this.parent = parent;
|
||||
this.customPasteViewIds = customPasteViewIds;
|
||||
}
|
||||
|
||||
public ClipboardStatus getMode()
|
||||
{
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
if (this.name == null)
|
||||
{
|
||||
this.name = (String)getServiceRegistry().getNodeService().getProperty(
|
||||
this.ref, ContentModel.PROP_NAME);
|
||||
}
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public QName getType()
|
||||
{
|
||||
if (this.type == null)
|
||||
{
|
||||
this.type = getServiceRegistry().getNodeService().getType(this.ref);
|
||||
}
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public String getIcon()
|
||||
{
|
||||
if (this.icon == null)
|
||||
{
|
||||
this.icon = (String)getServiceRegistry().getNodeService().getProperty(
|
||||
this.ref, ApplicationModel.PROP_ICON);
|
||||
}
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
public NodeRef getParent()
|
||||
{
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override equals() to compare NodeRefs
|
||||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof ClipboardItem)
|
||||
{
|
||||
return ((ClipboardItem)obj).getNodeRef().equals(this.ref);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override hashCode() to use the internal NodeRef hashcode instead
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
protected ServiceRegistry getServiceRegistry()
|
||||
{
|
||||
if (services == null)
|
||||
{
|
||||
services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
|
||||
}
|
||||
return services;
|
||||
}
|
||||
|
||||
public boolean canCopyToViewId(String viewId)
|
||||
{
|
||||
if (this.customPasteViewIds != null)
|
||||
{
|
||||
return this.customPasteViewIds.contains(viewId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canMoveToViewId(String viewId)
|
||||
{
|
||||
if (this.customPasteViewIds != null)
|
||||
{
|
||||
return this.customPasteViewIds.contains(viewId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean checkExists(String name, NodeRef parent)
|
||||
{
|
||||
QueryParameterDefinition[] params = new QueryParameterDefinition[1];
|
||||
params[0] = new QueryParameterDefImpl(
|
||||
ContentModel.PROP_NAME,
|
||||
getServiceRegistry().getDictionaryService().getDataType(
|
||||
DataTypeDefinition.TEXT),
|
||||
true,
|
||||
name);
|
||||
|
||||
// execute the query
|
||||
List<NodeRef> nodeRefs = getServiceRegistry().getSearchService().selectNodes(
|
||||
parent,
|
||||
XPATH_QUERY_NODE_MATCH,
|
||||
params,
|
||||
getServiceRegistry().getNamespaceService(),
|
||||
false);
|
||||
|
||||
return (nodeRefs.size() != 0);
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.bean.clipboard;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
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.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.search.QueryParameterDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Base class representing a single item added to the clipboard.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
abstract class AbstractClipboardItem implements ClipboardItem
|
||||
{
|
||||
protected static Log logger = LogFactory.getLog(ClipboardBean.class);
|
||||
|
||||
protected static final String MSG_COPY_OF = "copy_of";
|
||||
|
||||
/** Shallow search for nodes with a name pattern */
|
||||
private static final String XPATH_QUERY_NODE_MATCH = "./*[like(@cm:name, $cm:name, false)]";
|
||||
|
||||
transient private ServiceRegistry services = null;
|
||||
|
||||
protected NodeRef ref;
|
||||
protected NodeRef parent;
|
||||
protected ClipboardStatus mode;
|
||||
|
||||
// cached values
|
||||
private String name;
|
||||
private QName type;
|
||||
private String icon;
|
||||
|
||||
private List<String> customPasteViewIds;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ref The ref of the item on the clipboard
|
||||
* @param mode The ClipboardStatus enum value
|
||||
*/
|
||||
public AbstractClipboardItem(NodeRef ref, ClipboardStatus mode, List<String> customPasteViewIds)
|
||||
{
|
||||
this.ref = ref;
|
||||
this.mode = mode;
|
||||
this.customPasteViewIds = customPasteViewIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ref The ref of the item on the clipboard
|
||||
* @param parent The parent of the item on the clipboard
|
||||
* @param mode The ClipboardStatus enum value
|
||||
*/
|
||||
public AbstractClipboardItem(NodeRef ref, NodeRef parent, ClipboardStatus mode, List<String> customPasteViewIds)
|
||||
{
|
||||
this.ref = ref;
|
||||
this.mode = mode;
|
||||
this.parent = parent;
|
||||
this.customPasteViewIds = customPasteViewIds;
|
||||
}
|
||||
|
||||
public ClipboardStatus getMode()
|
||||
{
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
if (this.name == null)
|
||||
{
|
||||
this.name = (String)getServiceRegistry().getNodeService().getProperty(
|
||||
this.ref, ContentModel.PROP_NAME);
|
||||
}
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public QName getType()
|
||||
{
|
||||
if (this.type == null)
|
||||
{
|
||||
this.type = getServiceRegistry().getNodeService().getType(this.ref);
|
||||
}
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public String getIcon()
|
||||
{
|
||||
if (this.icon == null)
|
||||
{
|
||||
this.icon = (String)getServiceRegistry().getNodeService().getProperty(
|
||||
this.ref, ApplicationModel.PROP_ICON);
|
||||
}
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
public NodeRef getParent()
|
||||
{
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override equals() to compare NodeRefs
|
||||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof ClipboardItem)
|
||||
{
|
||||
return ((ClipboardItem)obj).getNodeRef().equals(this.ref);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override hashCode() to use the internal NodeRef hashcode instead
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
protected ServiceRegistry getServiceRegistry()
|
||||
{
|
||||
if (services == null)
|
||||
{
|
||||
services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
|
||||
}
|
||||
return services;
|
||||
}
|
||||
|
||||
public boolean canCopyToViewId(String viewId)
|
||||
{
|
||||
if (this.customPasteViewIds != null)
|
||||
{
|
||||
return this.customPasteViewIds.contains(viewId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canMoveToViewId(String viewId)
|
||||
{
|
||||
if (this.customPasteViewIds != null)
|
||||
{
|
||||
return this.customPasteViewIds.contains(viewId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean checkExists(String name, NodeRef parent)
|
||||
{
|
||||
QueryParameterDefinition[] params = new QueryParameterDefinition[1];
|
||||
params[0] = new QueryParameterDefImpl(
|
||||
ContentModel.PROP_NAME,
|
||||
getServiceRegistry().getDictionaryService().getDataType(
|
||||
DataTypeDefinition.TEXT),
|
||||
true,
|
||||
name);
|
||||
|
||||
// execute the query
|
||||
List<NodeRef> nodeRefs = getServiceRegistry().getSearchService().selectNodes(
|
||||
parent,
|
||||
XPATH_QUERY_NODE_MATCH,
|
||||
params,
|
||||
getServiceRegistry().getNamespaceService(),
|
||||
false);
|
||||
|
||||
return (nodeRefs.size() != 0);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user