mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-02 17:35:18 +00:00
. JavaScript API inter-store copy support
- Transparent support for inter-store copy added to JavaScript Node and AVMNode implementations The existing API mechanisms for copy() now support passing of Node or AVMNode and visa-versa as the destination target No changes to existing copy() semantics and no new services/APIs to learn . Improvements to handling of missing input parameters in JavaScript Node APIs . Added Workspace->Workspace support to CrossRepositoryCopyService git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5047 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
92c73dd54a
commit
d781cc74c1
@ -99,4 +99,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="crossCopyScript" parent="baseScriptImplementation" class="org.alfresco.repo.jscript.CrossRepositoryCopy">
|
||||||
|
<property name="scriptName">
|
||||||
|
<value>crossRepoCopy</value>
|
||||||
|
</property>
|
||||||
|
<property name="serviceRegistry">
|
||||||
|
<ref bean="ServiceRegistry"/>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
@ -20,6 +20,7 @@ import org.alfresco.service.cmr.avm.AVMService;
|
|||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
import org.alfresco.service.cmr.repository.CopyService;
|
import org.alfresco.service.cmr.repository.CopyService;
|
||||||
import org.alfresco.service.cmr.repository.CrossRepositoryCopyService;
|
import org.alfresco.service.cmr.repository.CrossRepositoryCopyService;
|
||||||
@ -117,24 +118,24 @@ public class CrossRepositoryCopyServiceImpl implements
|
|||||||
{
|
{
|
||||||
StoreRef srcStoreRef = src.getStoreRef();
|
StoreRef srcStoreRef = src.getStoreRef();
|
||||||
StoreRef dstStoreRef = dst.getStoreRef();
|
StoreRef dstStoreRef = dst.getStoreRef();
|
||||||
if (srcStoreRef.getProtocol().equals("avm"))
|
if (srcStoreRef.getProtocol().equals(StoreRef.PROTOCOL_AVM))
|
||||||
{
|
{
|
||||||
if (dstStoreRef.getProtocol().equals("avm"))
|
if (dstStoreRef.getProtocol().equals(StoreRef.PROTOCOL_AVM))
|
||||||
{
|
{
|
||||||
copyAVMToAVM(src, dst, name);
|
copyAVMToAVM(src, dst, name);
|
||||||
}
|
}
|
||||||
else
|
else if (dstStoreRef.getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE))
|
||||||
{
|
{
|
||||||
copyAVMToRepo(src, dst, name);
|
copyAVMToRepo(src, dst, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (srcStoreRef.getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE))
|
||||||
{
|
{
|
||||||
if (dstStoreRef.getProtocol().equals("avm"))
|
if (dstStoreRef.getProtocol().equals(StoreRef.PROTOCOL_AVM))
|
||||||
{
|
{
|
||||||
copyRepoToAVM(src, dst, name);
|
copyRepoToAVM(src, dst, name);
|
||||||
}
|
}
|
||||||
else
|
else if (dstStoreRef.getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE))
|
||||||
{
|
{
|
||||||
copyRepoToRepo(src, dst, name);
|
copyRepoToRepo(src, dst, name);
|
||||||
}
|
}
|
||||||
@ -277,6 +278,8 @@ public class CrossRepositoryCopyServiceImpl implements
|
|||||||
*/
|
*/
|
||||||
private void copyRepoToRepo(NodeRef src, NodeRef dst, String name)
|
private void copyRepoToRepo(NodeRef src, NodeRef dst, String name)
|
||||||
{
|
{
|
||||||
|
ChildAssociationRef assocRef = fNodeService.getPrimaryParent(src);
|
||||||
|
fCopyService.copyAndRename(src, dst, ContentModel.ASSOC_CONTAINS, assocRef.getQName(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyData(InputStream in, OutputStream out)
|
private void copyData(InputStream in, OutputStream out)
|
||||||
|
@ -19,7 +19,8 @@ package org.alfresco.repo.jscript;
|
|||||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
import org.alfresco.util.Pair;
|
||||||
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.mozilla.javascript.Scriptable;
|
import org.mozilla.javascript.Scriptable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,6 +32,7 @@ import org.mozilla.javascript.Scriptable;
|
|||||||
public class AVMNode extends Node
|
public class AVMNode extends Node
|
||||||
{
|
{
|
||||||
private String path;
|
private String path;
|
||||||
|
private int version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -41,8 +43,7 @@ public class AVMNode extends Node
|
|||||||
*/
|
*/
|
||||||
public AVMNode(NodeRef nodeRef, ServiceRegistry services)
|
public AVMNode(NodeRef nodeRef, ServiceRegistry services)
|
||||||
{
|
{
|
||||||
super(nodeRef, services);
|
this(nodeRef, services, null);
|
||||||
this.path = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,11 +57,13 @@ public class AVMNode extends Node
|
|||||||
public AVMNode(NodeRef nodeRef, ServiceRegistry services, Scriptable scope)
|
public AVMNode(NodeRef nodeRef, ServiceRegistry services, Scriptable scope)
|
||||||
{
|
{
|
||||||
super(nodeRef, services, scope);
|
super(nodeRef, services, scope);
|
||||||
this.path = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond();
|
Pair<Integer, String> versionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
|
||||||
|
this.path = versionPath.getSecond();
|
||||||
|
this.version = versionPath.getFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method
|
* Factory methods
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Node newInstance(NodeRef nodeRef, ServiceRegistry services, Scriptable scope)
|
public Node newInstance(NodeRef nodeRef, ServiceRegistry services, Scriptable scope)
|
||||||
@ -68,6 +71,11 @@ public class AVMNode extends Node
|
|||||||
return new AVMNode(nodeRef, services, scope);
|
return new AVMNode(nodeRef, services, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Node newInstance(String path, int version, ServiceRegistry services, Scriptable scope)
|
||||||
|
{
|
||||||
|
return new AVMNode(AVMNodeConverter.ToNodeRef(version, path), services, scope);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: changing the 'name' property (either directly using .name or with .properties.name)
|
// TODO: changing the 'name' property (either directly using .name or with .properties.name)
|
||||||
// invalidates the path and the base noderef instance!
|
// invalidates the path and the base noderef instance!
|
||||||
// AVMService has a specific rename method - use this and block name property changes?
|
// AVMService has a specific rename method - use this and block name property changes?
|
||||||
@ -85,6 +93,16 @@ public class AVMNode extends Node
|
|||||||
return getPath();
|
return getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getVersion()
|
||||||
|
{
|
||||||
|
return this.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int jsGet_version()
|
||||||
|
{
|
||||||
|
return getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy this Node into a new parent destination.
|
* Copy this Node into a new parent destination.
|
||||||
*
|
*
|
||||||
@ -95,14 +113,9 @@ public class AVMNode extends Node
|
|||||||
@Override
|
@Override
|
||||||
public Node copy(Node destination)
|
public Node copy(Node destination)
|
||||||
{
|
{
|
||||||
Node copy = null;
|
ParameterCheck.mandatory("Destination Node", destination);
|
||||||
|
|
||||||
if (destination instanceof AVMNode)
|
return getCrossRepositoryCopyHelper().copy(this, destination, getName());
|
||||||
{
|
|
||||||
copy = copy(((AVMNode)destination).getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,19 +127,14 @@ public class AVMNode extends Node
|
|||||||
*/
|
*/
|
||||||
public Node copy(String destination)
|
public Node copy(String destination)
|
||||||
{
|
{
|
||||||
Node copy = null;
|
ParameterCheck.mandatoryString("Destination Path", destination);
|
||||||
|
|
||||||
if (destination != null && destination.length() != 0)
|
this.services.getAVMService().copy(this.version, this.path, destination, getName());
|
||||||
{
|
return newInstance(
|
||||||
this.services.getAVMService().copy(-1, getPath(), destination, getName());
|
AVMNodeConverter.ToNodeRef(-1, AVMNodeConverter.ExtendAVMPath(destination, getName())),
|
||||||
copy = newInstance(
|
|
||||||
AVMNodeConverter.ToNodeRef(-1, destination + '/' + getName()),
|
|
||||||
this.services, this.scope);
|
this.services, this.scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move this Node to a new parent destination node.
|
* Move this Node to a new parent destination node.
|
||||||
*
|
*
|
||||||
@ -137,6 +145,8 @@ public class AVMNode extends Node
|
|||||||
@Override
|
@Override
|
||||||
public boolean move(Node destination)
|
public boolean move(Node destination)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatory("Destination Node", destination);
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
||||||
if (destination instanceof AVMNode)
|
if (destination instanceof AVMNode)
|
||||||
@ -156,6 +166,8 @@ public class AVMNode extends Node
|
|||||||
*/
|
*/
|
||||||
public boolean move(String destination)
|
public boolean move(String destination)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatoryString("Destination Path", destination);
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
||||||
if (destination != null && destination.length() != 0)
|
if (destination != null && destination.length() != 0)
|
||||||
@ -164,7 +176,7 @@ public class AVMNode extends Node
|
|||||||
this.services.getAVMService().rename(
|
this.services.getAVMService().rename(
|
||||||
parent.getPath(), getName(), destination, getName());
|
parent.getPath(), getName(), destination, getName());
|
||||||
|
|
||||||
reset(destination + '/' + getName());
|
reset(AVMNodeConverter.ExtendAVMPath(destination, getName()));
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@ -181,6 +193,8 @@ public class AVMNode extends Node
|
|||||||
*/
|
*/
|
||||||
public boolean rename(String name)
|
public boolean rename(String name)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatoryString("Destination name", name);
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
||||||
if (name != null && name.length() != 0)
|
if (name != null && name.length() != 0)
|
||||||
@ -189,7 +203,7 @@ public class AVMNode extends Node
|
|||||||
this.services.getAVMService().rename(
|
this.services.getAVMService().rename(
|
||||||
parentPath, getName(), parentPath, name);
|
parentPath, getName(), parentPath, name);
|
||||||
|
|
||||||
reset(parentPath + '/' + name);
|
reset(AVMNodeConverter.ExtendAVMPath(parentPath, name));
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@ -204,14 +218,14 @@ public class AVMNode extends Node
|
|||||||
{
|
{
|
||||||
super.reset();
|
super.reset();
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.nodeRef = AVMNodeConverter.ToNodeRef(-1, path);
|
this.nodeRef = AVMNodeConverter.ToNodeRef(version, path);
|
||||||
this.id = nodeRef.getId();
|
this.id = nodeRef.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
if (this.services.getAVMService().lookup(-1, this.path) != null)
|
if (this.services.getAVMService().lookup(version, this.path) != null)
|
||||||
{
|
{
|
||||||
return "AVM Path: " + getPath() +
|
return "AVM Path: " + getPath() +
|
||||||
"\nNode Type: " + getType() +
|
"\nNode Type: " + getType() +
|
||||||
|
103
source/java/org/alfresco/repo/jscript/CrossRepositoryCopy.java
Normal file
103
source/java/org/alfresco/repo/jscript/CrossRepositoryCopy.java
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* 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.repo.jscript;
|
||||||
|
|
||||||
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
|
import org.alfresco.service.ServiceRegistry;
|
||||||
|
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
|
import org.alfresco.util.ParameterCheck;
|
||||||
|
import org.mozilla.javascript.Scriptable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper bean to access Cross Repository copy services from a script context.
|
||||||
|
*
|
||||||
|
* @author Kevin Roast
|
||||||
|
*/
|
||||||
|
public final class CrossRepositoryCopy extends BaseScriptImplementation implements Scopeable
|
||||||
|
{
|
||||||
|
public final static String BEAN_NAME = "crossCopyScript";
|
||||||
|
|
||||||
|
/** Service registry */
|
||||||
|
private ServiceRegistry services;
|
||||||
|
|
||||||
|
/** Root scope for this object */
|
||||||
|
private Scriptable scope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.repo.jscript.Scopeable#setScope(org.mozilla.javascript.Scriptable)
|
||||||
|
*/
|
||||||
|
public void setScope(Scriptable scope)
|
||||||
|
{
|
||||||
|
this.scope = scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the service registry
|
||||||
|
*
|
||||||
|
* @param services the service registry
|
||||||
|
*/
|
||||||
|
public void setServiceRegistry(ServiceRegistry services)
|
||||||
|
{
|
||||||
|
this.services = services;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform a copy of a source node to the specified parent destination node. The name will
|
||||||
|
* be applied to the destination node copy.
|
||||||
|
* <p>
|
||||||
|
* Inter-store copy operations between Workspace and AVM and visa-versa are supported.
|
||||||
|
*
|
||||||
|
* @param src Source node instance
|
||||||
|
* @param dest Destination parent node instance
|
||||||
|
* @param name Name of the node copy
|
||||||
|
*
|
||||||
|
* @return node representing the copy if successful, null on unsupported store type.
|
||||||
|
*
|
||||||
|
* @throws org.alfresco.error.AlfrescoRuntimeException on copy error
|
||||||
|
*/
|
||||||
|
public Node copy(Node src, Node dest, String name)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("Node source", src);
|
||||||
|
ParameterCheck.mandatory("Node destination", dest);
|
||||||
|
ParameterCheck.mandatory("Node destination name", name);
|
||||||
|
|
||||||
|
Node result = null;
|
||||||
|
|
||||||
|
// perform the copy operation using the repository service
|
||||||
|
this.services.getCrossRepositoryCopyService().copy(src.getNodeRef(), dest.getNodeRef(), name);
|
||||||
|
|
||||||
|
// if we get here then copy succeeded - retrieve the new node reference
|
||||||
|
if (dest.getNodeRef().getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
|
||||||
|
{
|
||||||
|
Pair<Integer, String> versionPath = AVMNodeConverter.ToAVMVersionPath(dest.getNodeRef());
|
||||||
|
String destPath = AVMNodeConverter.ExtendAVMPath(versionPath.getSecond(), name);
|
||||||
|
AVMNodeDescriptor node = this.services.getAVMService().lookup(-1, destPath);
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
result = ((AVMNode)dest).newInstance(destPath, -1, this.services, this.scope);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (dest.getNodeRef().getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE))
|
||||||
|
{
|
||||||
|
result = dest.childByNamePath(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -49,6 +49,7 @@ import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
|||||||
import org.alfresco.service.cmr.repository.NoTransformerException;
|
import org.alfresco.service.cmr.repository.NoTransformerException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||||
import org.alfresco.service.cmr.repository.TemplateNode;
|
import org.alfresco.service.cmr.repository.TemplateNode;
|
||||||
import org.alfresco.service.cmr.security.AccessStatus;
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
@ -58,6 +59,8 @@ import org.alfresco.service.cmr.version.VersionType;
|
|||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.mozilla.javascript.Scriptable;
|
import org.mozilla.javascript.Scriptable;
|
||||||
@ -544,6 +547,8 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public boolean hasPermission(String permission)
|
public boolean hasPermission(String permission)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatory("Permission Name", permission);
|
||||||
|
|
||||||
boolean allowed = false;
|
boolean allowed = false;
|
||||||
|
|
||||||
if (permission != null && permission.length() != 0)
|
if (permission != null && permission.length() != 0)
|
||||||
@ -670,6 +675,7 @@ public class Node implements Serializable, Scopeable
|
|||||||
return getPrimaryParentAssoc();
|
return getPrimaryParentAssoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Content API
|
// Content API
|
||||||
|
|
||||||
@ -843,6 +849,7 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public void setPermission(String permission)
|
public void setPermission(String permission)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatoryString("Permission Name", permission);
|
||||||
this.services.getPermissionService().setPermission(this.nodeRef, PermissionService.ALL_AUTHORITIES, permission,
|
this.services.getPermissionService().setPermission(this.nodeRef, PermissionService.ALL_AUTHORITIES, permission,
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
@ -855,6 +862,8 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public void setPermission(String permission, String authority)
|
public void setPermission(String permission, String authority)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatoryString("Permission Name", permission);
|
||||||
|
ParameterCheck.mandatoryString("Authority", authority);
|
||||||
this.services.getPermissionService().setPermission(this.nodeRef, authority, permission, true);
|
this.services.getPermissionService().setPermission(this.nodeRef, authority, permission, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -865,6 +874,7 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public void removePermission(String permission)
|
public void removePermission(String permission)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatoryString("Permission Name", permission);
|
||||||
this.services.getPermissionService()
|
this.services.getPermissionService()
|
||||||
.deletePermission(this.nodeRef, PermissionService.ALL_AUTHORITIES, permission);
|
.deletePermission(this.nodeRef, PermissionService.ALL_AUTHORITIES, permission);
|
||||||
}
|
}
|
||||||
@ -877,6 +887,8 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public void removePermission(String permission, String authority)
|
public void removePermission(String permission, String authority)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatoryString("Permission Name", permission);
|
||||||
|
ParameterCheck.mandatoryString("Authority", authority);
|
||||||
this.services.getPermissionService().deletePermission(this.nodeRef, authority, permission);
|
this.services.getPermissionService().deletePermission(this.nodeRef, authority, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -955,6 +967,8 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public boolean specializeType(String type)
|
public boolean specializeType(String type)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatoryString("Type", type);
|
||||||
|
|
||||||
QName qnameType = createQName(type);
|
QName qnameType = createQName(type);
|
||||||
|
|
||||||
// Ensure that we are performing a specialise
|
// Ensure that we are performing a specialise
|
||||||
@ -1126,16 +1140,23 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public Node copy(Node destination, boolean deepCopy)
|
public Node copy(Node destination, boolean deepCopy)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatory("Destination Node", destination);
|
||||||
|
|
||||||
Node copy = null;
|
Node copy = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (destination != null)
|
if (destination.getNodeRef().getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE))
|
||||||
{
|
{
|
||||||
NodeRef copyRef = this.services.getCopyService().copyAndRename(this.nodeRef, destination.getNodeRef(),
|
NodeRef copyRef = this.services.getCopyService().copyAndRename(this.nodeRef, destination.getNodeRef(),
|
||||||
ContentModel.ASSOC_CONTAINS, getPrimaryParentAssoc().getQName(), deepCopy);
|
ContentModel.ASSOC_CONTAINS, getPrimaryParentAssoc().getQName(), deepCopy);
|
||||||
copy = newInstance(copyRef, this.services, this.scope);
|
copy = newInstance(copyRef, this.services, this.scope);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// NOTE: the deepCopy flag is not respected for this copy mechanism
|
||||||
|
copy = getCrossRepositoryCopyHelper().copy(this, destination, getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (AccessDeniedException accessErr)
|
catch (AccessDeniedException accessErr)
|
||||||
{
|
{
|
||||||
@ -1158,11 +1179,11 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public boolean move(Node destination)
|
public boolean move(Node destination)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatory("Destination Node", destination);
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
|
||||||
if (destination != null)
|
|
||||||
{
|
{
|
||||||
this.primaryParentAssoc = this.nodeService.moveNode(this.nodeRef, destination.getNodeRef(),
|
this.primaryParentAssoc = this.nodeService.moveNode(this.nodeRef, destination.getNodeRef(),
|
||||||
ContentModel.ASSOC_CONTAINS, getPrimaryParentAssoc().getQName());
|
ContentModel.ASSOC_CONTAINS, getPrimaryParentAssoc().getQName());
|
||||||
@ -1172,7 +1193,6 @@ public class Node implements Serializable, Scopeable
|
|||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (AccessDeniedException accessErr)
|
catch (AccessDeniedException accessErr)
|
||||||
{
|
{
|
||||||
// default of false will be returned
|
// default of false will be returned
|
||||||
@ -1208,10 +1228,10 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public boolean addAspect(String type, Object props)
|
public boolean addAspect(String type, Object props)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatoryString("Aspect Type", type);
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
||||||
if (type != null && type.length() != 0)
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> aspectProps = null;
|
Map<QName, Serializable> aspectProps = null;
|
||||||
@ -1250,7 +1270,6 @@ public class Node implements Serializable, Scopeable
|
|||||||
{
|
{
|
||||||
// default of failed will be returned
|
// default of failed will be returned
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@ -1264,20 +1283,15 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public boolean removeAspect(String type)
|
public boolean removeAspect(String type)
|
||||||
{
|
{
|
||||||
boolean success = false;
|
ParameterCheck.mandatoryString("Aspect Type", type);
|
||||||
|
|
||||||
if (type != null && type.length() != 0)
|
|
||||||
{
|
|
||||||
QName aspectQName = createQName(type);
|
QName aspectQName = createQName(type);
|
||||||
this.nodeService.removeAspect(this.nodeRef, aspectQName);
|
this.nodeService.removeAspect(this.nodeRef, aspectQName);
|
||||||
|
|
||||||
// reset the relevant cached node members
|
// reset the relevant cached node members
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
success = true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1310,6 +1324,8 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public Node checkout(Node destination)
|
public Node checkout(Node destination)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatory("Destination Node", destination);
|
||||||
|
|
||||||
ChildAssociationRef childAssocRef = this.nodeService.getPrimaryParent(destination.getNodeRef());
|
ChildAssociationRef childAssocRef = this.nodeService.getPrimaryParent(destination.getNodeRef());
|
||||||
NodeRef workingCopyRef = this.services.getCheckOutCheckInService().checkout(this.nodeRef,
|
NodeRef workingCopyRef = this.services.getCheckOutCheckInService().checkout(this.nodeRef,
|
||||||
destination.getNodeRef(), ContentModel.ASSOC_CONTAINS, childAssocRef.getQName());
|
destination.getNodeRef(), ContentModel.ASSOC_CONTAINS, childAssocRef.getQName());
|
||||||
@ -1380,6 +1396,7 @@ public class Node implements Serializable, Scopeable
|
|||||||
return newInstance(original, this.services, this.scope);
|
return newInstance(original, this.services, this.scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Transformation and Rendering API
|
// Transformation and Rendering API
|
||||||
|
|
||||||
@ -1412,6 +1429,9 @@ public class Node implements Serializable, Scopeable
|
|||||||
|
|
||||||
private Node transformDocument(String mimetype, NodeRef destination)
|
private Node transformDocument(String mimetype, NodeRef destination)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatoryString("Mimetype", mimetype);
|
||||||
|
ParameterCheck.mandatory("Destination Node", destination);
|
||||||
|
|
||||||
// the delegate definition for transforming a document
|
// the delegate definition for transforming a document
|
||||||
Transformer transformer = new Transformer()
|
Transformer transformer = new Transformer()
|
||||||
{
|
{
|
||||||
@ -1519,6 +1539,7 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public Node transformImage(String mimetype, Node destination)
|
public Node transformImage(String mimetype, Node destination)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatory("Destination Node", destination);
|
||||||
return transformImage(mimetype, null, destination.getNodeRef());
|
return transformImage(mimetype, null, destination.getNodeRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1535,11 +1556,14 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public Node transformImage(String mimetype, String options, Node destination)
|
public Node transformImage(String mimetype, String options, Node destination)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatory("Destination Node", destination);
|
||||||
return transformImage(mimetype, options, destination.getNodeRef());
|
return transformImage(mimetype, options, destination.getNodeRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Node transformImage(String mimetype, final String options, NodeRef destination)
|
private Node transformImage(String mimetype, final String options, NodeRef destination)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatoryString("Mimetype", mimetype);
|
||||||
|
|
||||||
// the delegate definition for transforming an image
|
// the delegate definition for transforming an image
|
||||||
Transformer transformer = new Transformer()
|
Transformer transformer = new Transformer()
|
||||||
{
|
{
|
||||||
@ -1574,6 +1598,7 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public String processTemplate(Node template)
|
public String processTemplate(Node template)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatory("Template Node", template);
|
||||||
return processTemplate(template.getContent(), null, null);
|
return processTemplate(template.getContent(), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1588,6 +1613,7 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public String processTemplate(Node template, Object args)
|
public String processTemplate(Node template, Object args)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatory("Template Node", template);
|
||||||
return processTemplate(template.getContent(), null, (ScriptableObject) args);
|
return processTemplate(template.getContent(), null, (ScriptableObject) args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1600,6 +1626,7 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public String processTemplate(String template)
|
public String processTemplate(String template)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatoryString("Template", template);
|
||||||
return processTemplate(template, null, null);
|
return processTemplate(template, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1614,6 +1641,7 @@ public class Node implements Serializable, Scopeable
|
|||||||
*/
|
*/
|
||||||
public String processTemplate(String template, Object args)
|
public String processTemplate(String template, Object args)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatoryString("Template", template);
|
||||||
return processTemplate(template, null, (ScriptableObject) args);
|
return processTemplate(template, null, (ScriptableObject) args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1730,6 +1758,15 @@ public class Node implements Serializable, Scopeable
|
|||||||
this.primaryParentAssoc = null;
|
this.primaryParentAssoc = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return helper object to perform cross repository copy of JavaScript Node objects
|
||||||
|
*/
|
||||||
|
protected CrossRepositoryCopy getCrossRepositoryCopyHelper()
|
||||||
|
{
|
||||||
|
return (CrossRepositoryCopy)this.services.getService(
|
||||||
|
QName.createQName("", CrossRepositoryCopy.BEAN_NAME));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list or a single Node from executing an xpath against the parent Node.
|
* Return a list or a single Node from executing an xpath against the parent Node.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user