* It links the source noderef to the destination noderef.
* Code needs to be tested
* Refer to WorkspaceClipboardItem.
* @param sourceNodeRef the noderef which is to be linked
* @param destNodeRef where the new link to be put
*/
private void establishLinkages(NodeRef sourceNodeRef , NodeRef destNodeRef){
boolean operationComplete = false;
// 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.
// 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 = nodeService.getPrimaryParent(getNodeRef());
ChildAssociationRef assocRef = this.getServiceRegistry().getNodeService().getPrimaryParent(sourceNodeRef);
String name = getName(sourceNodeRef);
String linkTo ="Link to";
name = linkTo + ' ' + name;
//Now perform linking
// LINK operation
LOGGER.debug("Attempting to link node ID: " + sourceNodeRef + " into node: " + destNodeRef.toString());
// we create a special Link Object node that has a property to reference the original
// create the node using the nodeService (can only use FileFolderService for content)
String LINK_NODE_EXTENSION = ".url";
if (checkExists(name + LINK_NODE_EXTENSION, destNodeRef) == false)
{
Map
String newName = name + LINK_NODE_EXTENSION;
props.put(ContentModel.PROP_NAME, newName);
props.put(ContentModel.PROP_LINK_DESTINATION, sourceNodeRef);
DictionaryService dd = getServiceRegistry().getDictionaryService();
if (dd.isSubClass(getType(sourceNodeRef), ContentModel.TYPE_CONTENT))
{
// create File Link node
ChildAssociationRef childRef = this.getServiceRegistry().getNodeService().createNode(
destNodeRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName(assocRef.getQName().getNamespaceURI(), newName),
ApplicationModel.TYPE_FILELINK,
props);
// apply the titled aspect - title and description
Map
titledProps.put(ContentModel.PROP_TITLE, name);
titledProps.put(ContentModel.PROP_DESCRIPTION, name);
this.getServiceRegistry().getNodeService().addAspect(childRef.getChildRef(), ContentModel.ASPECT_TITLED, titledProps);
}
else
{
// create Folder link node
ChildAssociationRef childRef = this.getServiceRegistry().getNodeService().createNode(
destNodeRef,
ContentModel.ASSOC_CONTAINS,
assocRef.getQName(),
ApplicationModel.TYPE_FOLDERLINK,
props);
// apply the uifacets aspect - icon, title and description props
Map
uiFacetsProps.put(ApplicationModel.PROP_ICON, "space-icon-link");
uiFacetsProps.put(ContentModel.PROP_TITLE, name);
uiFacetsProps.put(ContentModel.PROP_DESCRIPTION, name);
this.getServiceRegistry().getNodeService().addAspect(childRef.getChildRef(), ApplicationModel.ASPECT_UIFACETS, uiFacetsProps);
}
// if we get here without an exception, the clipboard link operation was successful
operationComplete = true;
}
LOGGER.debug("Is Linkage operation complete????"+ operationComplete);
}
public String getName(NodeRef sourceNodeRef)
{
String name = (String)getServiceRegistry().getNodeService().getProperty(
sourceNodeRef, ContentModel.PROP_NAME);
return name;
}
protected boolean checkExists(String name, NodeRef parent)
{
/** Shallow search for nodes with a name pattern */
String XPATH_QUERY_NODE_MATCH = "./*[like(@cm:name, $cm:name, false)]";
QueryParameterDefinition[] params = new QueryParameterDefinition[1];
params[0] = new QueryParameterDefImpl(
ContentModel.PROP_NAME,
getServiceRegistry().getDictionaryService().getDataType(
DataTypeDefinition.TEXT),
true,
name);
// execute the query
List
parent,
XPATH_QUERY_NODE_MATCH,
params,
getServiceRegistry().getNamespaceService(),
false);
return (nodeRefs.size() != 0);
}
public QName getType(NodeRef nodeRef)
{
QName type = getServiceRegistry().getNodeService().getType(nodeRef);
return type;
}
Basu ,
ReplyDeleteUsing Java Backed webscript , I am able to create folders, but folder is not showing in Alfresco Explorer and in share also any idea ?
by sarath ks
sarathk.sasi@gmail.com
You can do using cmis.Its easy one.
DeleteI have done the same.
This comment has been removed by the author.
ReplyDeletehi can u tell me how can i do this program using open cmis.If its not possible using opencmis,can u tell which dependency or jar i should add to do this program.Thanks in advance
ReplyDelete