當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.addMixin方法代碼示例

本文整理匯總了Java中javax.jcr.Node.addMixin方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.addMixin方法的具體用法?Java Node.addMixin怎麽用?Java Node.addMixin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jcr.Node的用法示例。


在下文中一共展示了Node.addMixin方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createProject

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public RepositoryFile createProject(String projectName, User user,boolean classify) throws Exception{
	if(!permissionService.isAdmin()){
		throw new NoPermissionException();
	}
	repositoryInteceptor.createProject(projectName);
	Node rootNode=getRootNode();
	if(rootNode.hasNode(projectName)){
		throw new RuleException("Project ["+projectName+"] already exist.");
	}
	Node projectNode=rootNode.addNode(projectName);
	projectNode.addMixin("mix:versionable");
	projectNode.setProperty(FILE, true);
	projectNode.setProperty(CRATE_USER,user.getUsername());
	projectNode.setProperty(COMPANY_ID, user.getCompanyId());
	Calendar calendar = Calendar.getInstance();
	calendar.setTime(new Date());
	DateValue dateValue = new DateValue(calendar);
	projectNode.setProperty(CRATE_DATE, dateValue);
	session.save();
	createResourcePackageFile(projectName,user);
	createClientConfigFile(projectName, user);
	RepositoryFile projectFileInfo=buildProjectFile(projectNode, null ,classify,null);
	return projectFileInfo;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:26,代碼來源:RepositoryServiceImpl.java

示例2: lockPath

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public void lockPath(String path,User user) throws Exception{
	path = processPath(path);
	int pos=path.indexOf(":");
	if(pos!=-1){
		path=path.substring(0,pos);
	}
	Node rootNode=getRootNode();
	if (!rootNode.hasNode(path)) {
		throw new RuleException("File [" + path + "] not exist.");
	}
	Node fileNode = rootNode.getNode(path);
	String topAbsPath=fileNode.getPath();
	if(lockManager.isLocked(topAbsPath)){
		String owner=lockManager.getLock(topAbsPath).getLockOwner();
		throw new NodeLockException("【"+path+"】已被"+owner+"鎖定,您不能進行再次鎖定!");
	}
	List<Node> nodeList=new ArrayList<Node>();
	unlockAllChildNodes(fileNode, user, nodeList, path);
	for(Node node:nodeList){
		if(!lockManager.isLocked(node.getPath())){
			continue;
		}
		Lock lock=lockManager.getLock(node.getPath());
		lockManager.unlock(lock.getNode().getPath());
	}
	if(!fileNode.isNodeType(NodeType.MIX_LOCKABLE)){
		if (!fileNode.isCheckedOut()) {
			versionManager.checkout(fileNode.getPath());
		}
		fileNode.addMixin("mix:lockable");
		session.save();
	}
	lockManager.lock(topAbsPath, true, true, Long.MAX_VALUE, user.getUsername());				
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:36,代碼來源:RepositoryServiceImpl.java

示例3: createFileNode

import javax.jcr.Node; //導入方法依賴的package包/類
private void createFileNode(String path, String content,User user,boolean isFile) throws Exception{
	String createUser=user.getUsername();
	repositoryInteceptor.createFile(path,content);
	Node rootNode=getRootNode();
	path = processPath(path);
	try {
		if (rootNode.hasNode(path)) {
			throw new RuleException("File [" + path + "] already exist.");
		}
		Node fileNode = rootNode.addNode(path);
		fileNode.addMixin("mix:versionable");
		fileNode.addMixin("mix:lockable");
		Binary fileBinary = new BinaryImpl(content.getBytes());
		fileNode.setProperty(DATA, fileBinary);
		if(isFile){
			fileNode.setProperty(FILE, true);				
		}
		fileNode.setProperty(CRATE_USER, createUser);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		DateValue dateValue = new DateValue(calendar);
		fileNode.setProperty(CRATE_DATE, dateValue);
		session.save();
	} catch (Exception ex) {
		throw new RuleException(ex);
	}
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:28,代碼來源:RepositoryServiceImpl.java

示例4: getOrAddNodeByPath

import javax.jcr.Node; //導入方法依賴的package包/類
private Node getOrAddNodeByPath( Node baseNode, String name, String nodeType )
    throws RepositoryException
{
    Node node = baseNode;
    for ( String n : name.split( "/" ) )
    {
        node = JcrUtils.getOrAddNode( node, n );
        if ( nodeType != null )
        {
            node.addMixin( nodeType );
        }
    }
    return node;
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:15,代碼來源:JcrMetadataRepository.java

示例5: getOrAddProjectNode

import javax.jcr.Node; //導入方法依賴的package包/類
private Node getOrAddProjectNode( String repositoryId, String namespace, String projectId )
    throws RepositoryException
{
    Node namespaceNode = getOrAddNamespaceNode( repositoryId, namespace );
    Node node = JcrUtils.getOrAddNode( namespaceNode, projectId );
    node.addMixin( PROJECT_NODE_TYPE );
    return node;
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:9,代碼來源:JcrMetadataRepository.java

示例6: getOrAddProjectVersionNode

import javax.jcr.Node; //導入方法依賴的package包/類
private Node getOrAddProjectVersionNode( String repositoryId, String namespace, String projectId,
                                         String projectVersion )
    throws RepositoryException
{
    Node projectNode = getOrAddProjectNode( repositoryId, namespace, projectId );
    Node node = JcrUtils.getOrAddNode( projectNode, projectVersion );
    node.addMixin( PROJECT_VERSION_NODE_TYPE );
    return node;
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:10,代碼來源:JcrMetadataRepository.java

示例7: getOrAddArtifactNode

import javax.jcr.Node; //導入方法依賴的package包/類
private Node getOrAddArtifactNode( String repositoryId, String namespace, String projectId, String projectVersion,
                                   String id )
    throws RepositoryException
{
    Node versionNode = getOrAddProjectVersionNode( repositoryId, namespace, projectId, projectVersion );
    Node node = JcrUtils.getOrAddNode( versionNode, id );
    node.addMixin( ARTIFACT_NODE_TYPE );
    return node;
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:10,代碼來源:JcrMetadataRepository.java

示例8: setMixin

import javax.jcr.Node; //導入方法依賴的package包/類
/**
 * Sets the mixin.
 *
 * @param post the post
 * @param mixinName the mixin name
 */
private void setMixin(Resource post, String mixinName) {
	try {
       	Node postNode = post.adaptTo(Node.class);
       	postNode.addMixin(mixinName);
       } catch (Exception e) {
		e.printStackTrace();
	}		
}
 
開發者ID:auniverseaway,項目名稱:aem-touch-admin-console,代碼行數:15,代碼來源:UptimeEntryServlet.java

示例9: createDir

import javax.jcr.Node; //導入方法依賴的package包/類
public void createDir(String path,User user) throws Exception{
	if(!permissionService.isAdmin()){
		throw new NoPermissionException();
	}
	repositoryInteceptor.createDir(path);
	Node rootNode=getRootNode();
	path = processPath(path);
	if (rootNode.hasNode(path)) {
		throw new RuleException("Dir [" + path + "] already exist.");
	}
	boolean add = false;
	String[] subpaths = path.split("/");
	Node parentNode = rootNode;
	for (String subpath : subpaths) {
		if (StringUtils.isEmpty(subpath)) {
			continue;
		}
		String subDirs[] = subpath.split("\\.");
		for (String dir : subDirs) {
			if (StringUtils.isEmpty(dir)) {
				continue;
			}
			if (parentNode.hasNode(dir)) {
				parentNode = parentNode.getNode(dir);
			} else {
				parentNode = parentNode.addNode(dir);
				parentNode.addMixin("mix:versionable");
				parentNode.addMixin("mix:lockable");
				parentNode.setProperty(DIR_TAG, true);
				parentNode.setProperty(FILE, true);
				parentNode.setProperty(CRATE_USER,user.getUsername());
				Calendar calendar = Calendar.getInstance();
				calendar.setTime(new Date());
				DateValue dateValue = new DateValue(calendar);
				parentNode.setProperty(CRATE_DATE, dateValue);
				add = true;
			}
		}
	}
	if (add) {
		session.save();
	}
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:44,代碼來源:RepositoryServiceImpl.java

示例10: updateArtifact

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public void updateArtifact( String repositoryId, String namespace, String projectId, String projectVersion,
                            ArtifactMetadata artifactMeta )
    throws MetadataRepositoryException
{
    updateNamespace( repositoryId, namespace );

    try
    {
        Node node =
            getOrAddArtifactNode( repositoryId, namespace, projectId, projectVersion, artifactMeta.getId() );

        Calendar cal = Calendar.getInstance();
        cal.setTime( artifactMeta.getFileLastModified() );
        node.setProperty( JCR_LAST_MODIFIED, cal );

        cal = Calendar.getInstance();
        cal.setTime( artifactMeta.getWhenGathered() );
        node.setProperty( "whenGathered", cal );

        node.setProperty( "size", artifactMeta.getSize() );
        node.setProperty( "md5", artifactMeta.getMd5() );
        node.setProperty( "sha1", artifactMeta.getSha1() );

        node.setProperty( "version", artifactMeta.getVersion() );

        // iterate over available facets to update/add/remove from the artifactMetadata
        for ( String facetId : metadataFacetFactories.keySet() )
        {
            MetadataFacet metadataFacet = artifactMeta.getFacet( facetId );
            if ( metadataFacet == null )
            {
                continue;
            }
            if ( node.hasNode( facetId ) )
            {
                node.getNode( facetId ).remove();
            }
            if ( metadataFacet != null )
            {
                // recreate, to ensure properties are removed
                Node n = node.addNode( facetId );
                n.addMixin( FACET_NODE_TYPE );

                for ( Map.Entry<String, String> entry : metadataFacet.toProperties().entrySet() )
                {
                    n.setProperty( entry.getKey(), entry.getValue() );
                }
            }
        }
    }
    catch ( RepositoryException e )
    {
        throw new MetadataRepositoryException( e.getMessage(), e );
    }
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:57,代碼來源:JcrMetadataRepository.java

示例11: addMixinThrowsException

import javax.jcr.Node; //導入方法依賴的package包/類
@Test(expected = UnsupportedOperationException.class)
public void addMixinThrowsException() throws Exception {
	Node testObj = aNode("/content");
	
	testObj.addMixin(null);
}
 
開發者ID:quatico-solutions,項目名稱:aem-testing,代碼行數:7,代碼來源:MockNodeTest.java


注:本文中的javax.jcr.Node.addMixin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。