本文整理匯總了Java中org.alfresco.service.cmr.repository.NodeService.createNode方法的典型用法代碼示例。如果您正苦於以下問題:Java NodeService.createNode方法的具體用法?Java NodeService.createNode怎麽用?Java NodeService.createNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.alfresco.service.cmr.repository.NodeService
的用法示例。
在下文中一共展示了NodeService.createNode方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addForumNode
import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
/**
* Adds forum node
*
* @param nodeRef Paren node
* @return Reference to created node
*/
private NodeRef addForumNode(NodeRef nodeRef)
{
NodeService nodeService = getNodeService();
// //Add discussable aspect to content node
// if (!nodeService.hasAspect(nodeRef, ForumModel.ASPECT_DISCUSSABLE))
// {
// nodeService.addAspect(nodeRef, ForumModel.ASPECT_DISCUSSABLE, null);
// }
//Create forum node and associate it with content node
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(1);
properties.put(ContentModel.PROP_NAME, forumNodeName);
ChildAssociationRef childAssoc = nodeService.createNode(nodeRef, ForumModel.ASSOC_DISCUSSION, ForumModel.ASSOC_DISCUSSION, ForumModel.TYPE_FORUM, properties);
NodeRef forumNode = childAssoc.getChildRef();
//Add necessary aspects to forum node
properties.clear();
properties.put(ApplicationModel.PROP_ICON, "forum");
nodeService.addAspect(forumNode, ApplicationModel.ASPECT_UIFACETS, properties);
return forumNode;
}
示例2: addTopicNode
import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
/**
* Adds topic node into Alfresco repository
*
* @param parentNode Parent node
* @param name Topic name
* @return Reference to created node
*/
protected NodeRef addTopicNode(NodeRef parentNode, String name)
{
String workingName = encodeSubject(name);
NodeService nodeService = getNodeService();
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(1);
properties.put(ContentModel.PROP_NAME, workingName);
NodeRef topicNode = nodeService.getChildByName(parentNode, ContentModel.ASSOC_CONTAINS, workingName);
if (topicNode == null)
{
ChildAssociationRef association = nodeService.createNode(
parentNode,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, workingName),
ForumModel.TYPE_TOPIC,
properties);
topicNode = association.getChildRef();
}
// Add necessary aspects
properties.clear();
properties.put(ApplicationModel.PROP_ICON, "topic");
getNodeService().addAspect(topicNode, ApplicationModel.ASPECT_UIFACETS, properties);
return topicNode;
}
示例3: setUp
import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
@Override
public void setUp() throws Exception
{
ctx = ApplicationContextHelper.getApplicationContext();
transactionService = (TransactionService) ctx.getBean("TransactionService");
nodeService = (NodeService) ctx.getBean("NodeService");
contentService = (ContentService) ctx.getBean(ServiceRegistry.CONTENT_SERVICE.getLocalName());
this.policyComponent = (PolicyComponent) ctx.getBean("policyComponent");
this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
// authenticate
this.authenticationComponent.setSystemUserAsCurrentUser();
// start the transaction
txn = getUserTransaction();
txn.begin();
// create a store and get the root node
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, getName());
if (!nodeService.exists(storeRef))
{
storeRef = nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier());
}
rootNodeRef = nodeService.getRootNode(storeRef);
// create a content node
ContentData contentData = new ContentData(null, "text/plain", 0L, "UTF-16", Locale.CHINESE);
PropertyMap properties = new PropertyMap();
properties.put(ContentModel.PROP_CONTENT, contentData);
ChildAssociationRef assocRef = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(TEST_NAMESPACE, GUID.generate()),
ContentModel.TYPE_CONTENT,
properties);
contentNodeRef = assocRef.getChildRef();
}
示例4: createUser
import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
public static void createUser(
String userName,
String password,
String email,
NodeRef rootNodeRef,
NodeService nodeService,
MutableAuthenticationService authenticationService)
{
// ignore if the user's authentication already exists
if (authenticationService.authenticationExists(userName))
{
// ignore
return;
}
QName children = ContentModel.ASSOC_CHILDREN;
QName system = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "system");
QName container = ContentModel.TYPE_CONTAINER;
QName types = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "people");
NodeRef systemNodeRef = nodeService.createNode(rootNodeRef, children, system, container).getChildRef();
NodeRef typesNodeRef = nodeService.createNode(systemNodeRef, children, types, container).getChildRef();
HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(ContentModel.PROP_USERNAME, userName);
if (email != null && email.length() != 0)
{
properties.put(ContentModel.PROP_EMAIL, email);
}
nodeService.createNode(typesNodeRef, children, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, userName) , container, properties);
// Create the users
authenticationService.createAuthentication(userName, password.toCharArray());
}
示例5: createNode
import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
private NodeRef createNode(String cmName, NodeRef parentNode, QName nodeType)
{
final NodeService nodeService = (NodeService) appContextRule.getApplicationContext().getBean("nodeService");
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(ContentModel.PROP_NAME, cmName);
ChildAssociationRef childAssoc = nodeService.createNode(parentNode,
ContentModel.ASSOC_CONTAINS,
ContentModel.ASSOC_CONTAINS,
nodeType,
props);
return childAssoc.getChildRef();
}
示例6: makeAvatar
import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
public static String makeAvatar(final NodeService nodeService, final NodeRef person)
{
nodeService.addAspect(person, ContentModel.ASPECT_PREFERENCES, null);
ChildAssociationRef assoc = nodeService.createNode(person, ContentModel.ASSOC_PREFERENCE_IMAGE, avatarQName,
ContentModel.TYPE_CONTENT);
NodeRef avatar = assoc.getChildRef();
nodeService.createAssociation(person, avatar, ContentModel.ASSOC_AVATAR);
return "api/node/" + avatar + "/content/thumbnails/avatar";
}
示例7: addPostNode
import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
/**
* Posts content
*
* @param nodeRef Reference to node
* @param message Mail parser
* @return Returns the new post node
*/
protected NodeRef addPostNode(NodeRef nodeRef, EmailMessage message)
{
NodeService nodeService = getNodeService();
Date now = new Date();
String nodeName = "posted-" + new SimpleDateFormat("dd-MM-yyyy-hh-mm-ss").format(now) + ".html";
PropertyMap properties = new PropertyMap(3);
properties.put(ContentModel.PROP_NAME, nodeName);
NodeRef postNodeRef = nodeService.getChildByName(nodeRef, ContentModel.ASSOC_CONTAINS, nodeName);
if (postNodeRef == null)
{
ChildAssociationRef childAssoc = nodeService.createNode(
nodeRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, nodeName),
ForumModel.TYPE_POST,
properties);
postNodeRef = childAssoc.getChildRef();
}
// Add necessary aspects
properties.clear();
properties.put(ContentModel.PROP_TITLE, nodeName);
nodeService.addAspect(postNodeRef, ContentModel.ASPECT_TITLED, properties);
properties.clear();
properties.put(ApplicationModel.PROP_EDITINLINE, true);
nodeService.addAspect(postNodeRef, ApplicationModel.ASPECT_INLINEEDITABLE, properties);
// Write content
if (message.getBody() != null)
{
writeContent(
postNodeRef,
message.getBody().getContent(),
message.getBody().getContentType(),
message.getBody().getEncoding());
}
else
{
writeContent(postNodeRef, "<The message was empty>", MimetypeMap.MIMETYPE_TEXT_PLAIN);
}
addEmailedAspect(postNodeRef, message);
// Done
return postNodeRef;
}