本文整理匯總了Java中javax.jcr.Node.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.getName方法的具體用法?Java Node.getName怎麽用?Java Node.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jcr.Node
的用法示例。
在下文中一共展示了Node.getName方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: recurse
import javax.jcr.Node; //導入方法依賴的package包/類
private void recurse( List<String> facets, String prefix, Node node )
throws RepositoryException
{
for ( Node n : JcrUtils.getChildNodes( node ) )
{
String name = prefix + "/" + n.getName();
if ( n.hasNodes() )
{
recurse( facets, name, n );
}
else
{
// strip leading / first
facets.add( name.substring( 1 ) );
}
}
}
示例2: getDirectories
import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public List<RepositoryFile> getDirectories(String project) throws Exception {
Node rootNode=getRootNode();
NodeIterator nodeIterator = rootNode.getNodes();
Node targetProjectNode = null;
while (nodeIterator.hasNext()) {
Node projectNode = nodeIterator.nextNode();
if (!projectNode.hasProperty(FILE)) {
continue;
}
String projectName = projectNode.getName();
if (project != null && !project.equals(projectName)) {
continue;
}
targetProjectNode = projectNode;
break;
}
if (targetProjectNode == null) {
throw new RuleException("Project [" + project + "] not exist.");
}
List<RepositoryFile> fileList = new ArrayList<RepositoryFile>();
RepositoryFile root = new RepositoryFile();
root.setName("根目錄");
String projectPath = targetProjectNode.getPath();
root.setFullPath(projectPath);
fileList.add(root);
NodeIterator projectNodeIterator = targetProjectNode.getNodes();
while (projectNodeIterator.hasNext()) {
Node dirNode = projectNodeIterator.nextNode();
if (!dirNode.hasProperty(DIR_TAG)) {
continue;
}
RepositoryFile file = new RepositoryFile();
file.setName(dirNode.getPath().substring(projectPath.length()));
file.setFullPath(dirNode.getPath());
fileList.add(file);
buildDirectories(dirNode, fileList, projectPath);
}
return fileList;
}
示例3: lockCheck
import javax.jcr.Node; //導入方法依賴的package包/類
private void lockCheck(Node node,User user) throws Exception{
if(lockManager.isLocked(node.getPath())){
String lockOwner=lockManager.getLock(node.getPath()).getLockOwner();
if(lockOwner.equals(user.getUsername())){
return;
}
throw new NodeLockException("【"+node.getName()+"】已被"+lockOwner+"鎖定!");
}
}
示例4: loadRepository
import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public Repository loadRepository(String project,User user,boolean classify,FileType[] types,String searchFileName) throws Exception{
String companyId=user.getCompanyId();
createSecurityConfigFile(user);
if(project!=null && project.startsWith("/")){
project=project.substring(1,project.length());
}
Repository repo=new Repository();
List<String> projectNames=new ArrayList<String>();
repo.setProjectNames(projectNames);
RepositoryFile rootFile = new RepositoryFile();
rootFile.setFullPath("/");
rootFile.setName("項目列表");
rootFile.setType(Type.root);
Node rootNode=getRootNode();
NodeIterator nodeIterator = rootNode.getNodes();
while (nodeIterator.hasNext()) {
Node projectNode = nodeIterator.nextNode();
if (!projectNode.hasProperty(FILE)) {
continue;
}
if(StringUtils.isNotEmpty(companyId)){
if(projectNode.hasProperty(COMPANY_ID)){
String id=projectNode.getProperty(COMPANY_ID).getString();
if(!companyId.equals(id)){
continue;
}
}
}
String projectName = projectNode.getName();
if(projectName.indexOf(RESOURCE_SECURITY_CONFIG_FILE)>-1){
continue;
}
if (StringUtils.isNotBlank(project) && !project.equals(projectName)) {
continue;
}
if(!permissionService.projectHasPermission(projectNode.getPath())){
continue;
}
if(StringUtils.isBlank(project)){
projectNames.add(projectName);
}
RepositoryFile projectFile=buildProjectFile(projectNode,types,classify,searchFileName);
rootFile.addChild(projectFile, false);
}
repo.setRootFile(rootFile);
return repo;
}
示例5: getProjectReferences
import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public Collection<ProjectVersionReference> getProjectReferences( String repositoryId, String namespace,
String projectId, String projectVersion )
throws MetadataResolutionException
{
List<ProjectVersionReference> references = new ArrayList<>();
// TODO: bind variables instead
String q = "SELECT * FROM [archiva:dependency] WHERE ISDESCENDANTNODE([/repositories/" + repositoryId +
"/content]) AND [groupId]='" + namespace + "' AND [artifactId]='" + projectId + "'";
if ( projectVersion != null )
{
q += " AND [version]='" + projectVersion + "'";
}
try
{
Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
QueryResult result = query.execute();
for ( Node n : JcrUtils.getNodes( result ) )
{
n = n.getParent(); // dependencies grouping element
n = n.getParent(); // project version
String usedByProjectVersion = n.getName();
n = n.getParent(); // project
String usedByProject = n.getName();
n = n.getParent(); // namespace
String usedByNamespace = n.getProperty( "namespace" ).getString();
ProjectVersionReference ref = new ProjectVersionReference();
ref.setNamespace( usedByNamespace );
ref.setProjectId( usedByProject );
ref.setProjectVersion( usedByProjectVersion );
ref.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY );
references.add( ref );
}
}
catch ( RepositoryException e )
{
throw new MetadataResolutionException( e.getMessage(), e );
}
return references;
}
示例6: getArtifactFromNode
import javax.jcr.Node; //導入方法依賴的package包/類
private ArtifactMetadata getArtifactFromNode( String repositoryId, Node artifactNode )
throws RepositoryException
{
String id = artifactNode.getName();
ArtifactMetadata artifact = new ArtifactMetadata();
artifact.setId( id );
artifact.setRepositoryId( repositoryId == null ? artifactNode.getAncestor(2).getName() : repositoryId );
Node projectVersionNode = artifactNode.getParent();
Node projectNode = projectVersionNode.getParent();
Node namespaceNode = projectNode.getParent();
artifact.setNamespace( namespaceNode.getProperty( "namespace" ).getString() );
artifact.setProject( projectNode.getName() );
artifact.setProjectVersion( projectVersionNode.getName() );
artifact.setVersion( artifactNode.hasProperty( "version" )
? artifactNode.getProperty( "version" ).getString()
: projectVersionNode.getName() );
if ( artifactNode.hasProperty( JCR_LAST_MODIFIED ) )
{
artifact.setFileLastModified( artifactNode.getProperty( JCR_LAST_MODIFIED ).getDate().getTimeInMillis() );
}
if ( artifactNode.hasProperty( "whenGathered" ) )
{
artifact.setWhenGathered( artifactNode.getProperty( "whenGathered" ).getDate().getTime() );
}
if ( artifactNode.hasProperty( "size" ) )
{
artifact.setSize( artifactNode.getProperty( "size" ).getLong() );
}
if ( artifactNode.hasProperty( "md5" ) )
{
artifact.setMd5( artifactNode.getProperty( "md5" ).getString() );
}
if ( artifactNode.hasProperty( "sha1" ) )
{
artifact.setSha1( artifactNode.getProperty( "sha1" ).getString() );
}
for ( Node n : JcrUtils.getChildNodes( artifactNode ) )
{
if ( n.isNodeType( FACET_NODE_TYPE ) )
{
String name = n.getName();
MetadataFacetFactory factory = metadataFacetFactories.get( name );
if ( factory == null )
{
log.error( "Attempted to load unknown project version metadata facet: " + name );
}
else
{
MetadataFacet facet = factory.createMetadataFacet();
Map<String, String> map = new HashMap<>();
for ( Property p : JcrUtils.getProperties( n ) )
{
String property = p.getName();
if ( !property.startsWith( "jcr:" ) )
{
map.put( property, p.getString() );
}
}
facet.fromProperties( map );
artifact.addFacet( facet );
}
}
}
return artifact;
}