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


Java Node.hasProperty方法代碼示例

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


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

示例1: getSinglePropertyAs

import javax.jcr.Node; //導入方法依賴的package包/類
/**
 * Takes type, resource, and propertyName and returns its value of the object based on the given type
 *
 * @param type This is type parameter
 * @param resource The resource to fetch the value from
 * @param propertyName The property name to be used to fetch the value from the resource
 * @return value The value of the object based on the given type
 */
private static <T> T getSinglePropertyAs(Class<T> type, Resource resource, String propertyName) {
    T val = null;
    try {
        if (null != resource) {
            Node node = resource.adaptTo(Node.class);
            if (null != node) {
                if (node.hasProperty(propertyName)) {
                    Property property = node.getProperty(propertyName);
                    if (!property.isMultiple()) {
                        Value value = property.getValue();
                        val = PropertyUtils.as(type, value);
                    }
                }
            }
        }
    } catch (Exception e) {
        LOG.error(ERROR, e);
    }
    return val;
}
 
開發者ID:DantaFramework,項目名稱:AEM,代碼行數:29,代碼來源:ResourceUtils.java

示例2: getMultiplePropertyAs

import javax.jcr.Node; //導入方法依賴的package包/類
/**
 * Takes type, resource, and property name and returns the list of value of the object based on the given type
 *
 * @param type This is type parameter
 * @param resource The resource to fetch the value from
 * @param propertyName The property name to be used to fetch the value from the resource
 * @return valueList The list of values of the object based on the given type
 */
private static <T> List<T> getMultiplePropertyAs(Class<T> type, Resource resource, String propertyName) {
    List<T> val = Collections.EMPTY_LIST;
    try {
        if (null != resource) {
            Node node = resource.adaptTo(Node.class);
            if (null != node) {
                if (node.hasProperty(propertyName)) {
                    Property property = node.getProperty(propertyName);
                    if (property.isMultiple()) {
                        Value[] value = property.getValues();
                        val = PropertyUtils.as(type, value);
                    }
                }
            }
        }
    } catch (Exception e) {
        LOG.error(ERROR, e);
    }
    return val;
}
 
開發者ID:DantaFramework,項目名稱:AEM,代碼行數:29,代碼來源:ResourceUtils.java

示例3: buildDirectories

import javax.jcr.Node; //導入方法依賴的package包/類
private void buildDirectories(Node node, List<RepositoryFile> fileList, String projectPath) throws Exception {
	NodeIterator nodeIterator = node.getNodes();
	while (nodeIterator.hasNext()) {
		Node dirNode = nodeIterator.nextNode();
		if (!dirNode.hasProperty(FILE)) {
			continue;
		}
		if (!dirNode.hasProperty(DIR_TAG)) {
			continue;
		}
		RepositoryFile file = new RepositoryFile();
		file.setName(dirNode.getPath().substring(projectPath.length()));
		file.setFullPath(dirNode.getPath());
		buildDirectories(dirNode, fileList, projectPath);
		fileList.add(file);
	}
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:18,代碼來源:RepositoryServiceImpl.java

示例4: getPropertyValues

import javax.jcr.Node; //導入方法依賴的package包/類
private Value[] getPropertyValues(Node node, String propertyName) throws RepositoryException {
    if (node.hasProperty(propertyName)) {
        Property prop = node.getProperty(propertyName);
        Value[] values;

        // This check is necessary to ensure a multi-valued field is applied...
        if (prop.isMultiple()) {
            values = prop.getValues();
        } else {
            values = new Value[1];
            values[0] = prop.getValue();
        }

        return values;
    }

    return new Value[0];
}
 
開發者ID:HS2-SOLUTIONS,項目名稱:hs2-aem-commons,代碼行數:19,代碼來源:PropagatePropertyInheritanceCancelled.java

示例5: purge

import javax.jcr.Node; //導入方法依賴的package包/類
private void purge(final Context context, final ActionResult actionResult)
		throws RepositoryException, ActionExecutionException {
	NodeIterator iterator = getPermissions(context);
	String normalizedPath = normalizePath(path);
	while (iterator != null && iterator.hasNext()) {
		Node node = iterator.nextNode();
		if (node.hasProperty(PermissionConstants.REP_ACCESS_CONTROLLED_PATH)) {
			String parentPath = node.getProperty(PermissionConstants.REP_ACCESS_CONTROLLED_PATH)
					.getString();
			String normalizedParentPath = normalizePath(parentPath);
			boolean isUsersPermission = parentPath.startsWith(context.getCurrentAuthorizable().getPath());
			if (StringUtils.startsWith(normalizedParentPath, normalizedPath) && !isUsersPermission) {
				RemoveAll removeAll = new RemoveAll(parentPath);
				ActionResult removeAllResult = removeAll.execute(context);
				if (Status.ERROR.equals(removeAllResult.getStatus())) {
					actionResult.logError(removeAllResult);
				}
			}
		}
	}
}
 
開發者ID:Cognifide,項目名稱:APM,代碼行數:22,代碼來源:Purge.java

示例6: doGet

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
protected void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response)
        throws IOException, ServletException {
    //TODO: put all of the logic in a context processor (need to fix templating support filter bug first)
    String transformName = BLANK;
    if (PathInfoUtil.getSuffixSegments(request).length == 2) {
        String firstSuffixSegment = PathInfoUtil.getFirstSuffixSegment(request);
        if (this.namedImageTransformers.keySet().contains(firstSuffixSegment)) {
            transformName = firstSuffixSegment;
        }
    }
    //Adds the asset binary to the inputStream
    try {
        Resource assetResource = getAssetResource(request);

        if (DamUtil.isAsset(assetResource)) {
            Binary binary;
            String mimeType = BLANK;
            Asset asset = DamUtil.resolveToAsset(assetResource);
            Resource original = asset.getOriginal();

            Node assetNode = original.adaptTo(Node.class);
            if (assetNode.hasNode(JCR_CONTENT)) {
                Node assetInfo = assetNode.getNode(JCR_CONTENT);
                if (assetInfo.hasProperty(JCR_MIMETYPE)) {
                    mimeType = assetInfo.getProperty(JCR_MIMETYPE).getString();
                }
                if (StringUtils.isNotBlank(mimeType)) {
                    response.setContentType(mimeType);
                }
                binary = assetInfo.getProperty(JCR_DATA).getBinary();
                InputStream inputStream = binary.getStream();
                OutputStream outputStream = response.getOutputStream();

                boolean shouldTransform = StringUtils.isNotBlank(transformName);
                if (shouldTransform && ImageUtils.isImage(assetResource)) {
                    double quality = 1;
                    double maxGifQuality = 255;

                    // Transform the image
                    final Layer layer = new Layer(inputStream, new Dimension(maxWidth, maxHeight));
                    Layer newLayer = null;
                    try {
                        final NamedImageTransformer namedImageTransformer = this.namedImageTransformers.get(transformName);
                        newLayer = namedImageTransformer.transform(layer);

                        if (StringUtils.isBlank(mimeType) || !ImageIO.getImageWritersByMIMEType(mimeType).hasNext()) {
                            mimeType = getImageMimeType(layer, asset.getName());
                            response.setContentType(mimeType);
                        }
                        // For GIF images the colors will be reduced according to the quality argument.
                        if (StringUtils.equals(mimeType, GIF_MIME_TYPE)) {
                            quality = quality * maxGifQuality;
                        }

                        newLayer.write(mimeType, quality, outputStream);
                    } finally {
                        if (layer != null) {
                            layer.dispose();
                        }
                        if (newLayer != null) {
                            newLayer.dispose();
                        }
                    }

                } else {
                    ByteStreams.copy(inputStream, outputStream);
                }

                response.flushBuffer();
                outputStream.close();

            }
        }
    } catch (RepositoryException repoException) {
        LOGGER.error("Repository Exception. ", repoException);
    }
}
 
開發者ID:DantaFramework,項目名稱:AEM,代碼行數:80,代碼來源:AssetProviderServlet.java

示例7: getFieldExternalDocuments

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public ExternalDocumentCollection<JSONObject> getFieldExternalDocuments(ExternalDocumentServiceContext context) {
    final String fieldName = context.getPluginConfig().getString(PARAM_EXTERNAL_DOCS_FIELD_NAME);

    if (StringUtils.isBlank(fieldName)) {
        throw new IllegalArgumentException("Invalid plugin configuration parameter for '" + PARAM_EXTERNAL_DOCS_FIELD_NAME + "': " + fieldName);
    }

    ExternalDocumentCollection<JSONObject> docCollection = new SimpleExternalDocumentCollection<JSONObject>();

    try {
        final Node contextNode = context.getContextModel().getNode();

        if (contextNode.hasProperty(fieldName)) {
            Value[] values = contextNode.getProperty(fieldName).getValues();

            // This is where it checks which values are selected.
            for (Value value : values) {
                String id = value.getString();
                JSONObject doc = findDocumentById(id);

                if (doc != null) {
                    docCollection.add(doc);
                }
            }
        }
    } catch (RepositoryException e) {
        log.error("Failed to retrieve related exdoc array field.", e);
    }

    return docCollection;
}
 
開發者ID:jenskooij,項目名稱:hippo-external-document-picker-example-implementation,代碼行數:33,代碼來源:DocumentServiceFacade.java

示例8: loadProjects

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public List<RepositoryFile> loadProjects(String companyId) throws Exception{
	List<RepositoryFile> projects=new ArrayList<RepositoryFile>();
	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;
				}
			}
		}
		if(projectNode.getName().indexOf(RESOURCE_SECURITY_CONFIG_FILE)>-1){
			continue;
		}
		RepositoryFile projectFile = new RepositoryFile();
		projectFile.setType(Type.project);
		projectFile.setName(projectNode.getName());
		projectFile.setFullPath("/" + projectNode.getName());
		projects.add(projectFile);
	}
	return projects;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:30,代碼來源:BaseRepositoryService.java

示例9: getVersionFiles

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public List<VersionFile> getVersionFiles(String path) throws Exception{
	path = processPath(path);
	Node rootNode=getRootNode();
	if (!rootNode.hasNode(path)) {
		throw new RuleException("File [" + path + "] not exist.");
	}
	List<VersionFile> files = new ArrayList<VersionFile>();
	Node fileNode = rootNode.getNode(path);
	VersionHistory versionHistory = versionManager.getVersionHistory(fileNode.getPath());
	VersionIterator iterator = versionHistory.getAllVersions();
	while (iterator.hasNext()) {
		Version version = iterator.nextVersion();
		String versionName = version.getName();
		if (versionName.startsWith("jcr:")) {
			continue; // skip root version
		}
		Node fnode = version.getFrozenNode();
		VersionFile file = new VersionFile();
		file.setName(version.getName());
		file.setPath(fileNode.getPath());
		Property prop = fnode.getProperty(CRATE_USER);
		file.setCreateUser(prop.getString());
		prop = fnode.getProperty(CRATE_DATE);
		file.setCreateDate(prop.getDate().getTime());
		if(fnode.hasProperty(VERSION_COMMENT)){
			prop=fnode.getProperty(VERSION_COMMENT);
			file.setComment(prop.getString());
		}
		files.add(file);
	}
	return files;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:34,代碼來源:BaseRepositoryService.java

示例10: 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;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:41,代碼來源:RepositoryServiceImpl.java

示例11: generate

import javax.jcr.Node; //導入方法依賴的package包/類
private void generate(Node node) throws RepositoryException, IOException {
    Node originalNode = node.getNode(PATH_ORIGINAL);

    if (!originalNode.hasProperty("jcr:content/jcr:mimeType")) {
        log.warn("Ignoring [{}] as it does not defined the jcr:mimeType", originalNode.getPath());
        return;
    }

    workDir = Files.createTempDir();
    InputStream is = JcrUtils.readFile(originalNode);

    File original = copy(is, "original");
    Map<String, File> renditions = generate(original);
    copy(renditions, node.getNode("jcr:content/renditions"));
}
 
開發者ID:bdelacretaz,項目名稱:sling-adaptto-2016,代碼行數:16,代碼來源:RenditionGenerator.java

示例12: 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;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:49,代碼來源:RepositoryServiceImpl.java

示例13: removeArtifact

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public void removeArtifact( ArtifactMetadata artifactMetadata, String baseVersion )
    throws MetadataRepositoryException
{

    String repositoryId = artifactMetadata.getRepositoryId();

    try
    {
        Node root = getJcrSession().getRootNode();
        String path =
            getProjectVersionPath( repositoryId, artifactMetadata.getNamespace(), artifactMetadata.getProject(),
                                   baseVersion );

        if ( root.hasNode( path ) )
        {
            Node node = root.getNode( path );

            for ( Node n : JcrUtils.getChildNodes( node ) )
            {
                if ( n.isNodeType( ARTIFACT_NODE_TYPE ) )
                {
                    if ( n.hasProperty( "version" ) )
                    {
                        String version = n.getProperty( "version" ).getString();
                        if ( StringUtils.equals( version, artifactMetadata.getVersion() ) )
                        {
                            n.remove();
                        }
                    }

                }
            }
        }
    }
    catch ( RepositoryException e )
    {
        throw new MetadataRepositoryException( e.getMessage(), e );
    }


}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:43,代碼來源:JcrMetadataRepository.java

示例14: 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;
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:75,代碼來源:JcrMetadataRepository.java

示例15: getPropertyString

import javax.jcr.Node; //導入方法依賴的package包/類
private static String getPropertyString( Node node, String name )
    throws RepositoryException
{
    return node.hasProperty( name ) ? node.getProperty( name ).getString() : null;
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:6,代碼來源:JcrMetadataRepository.java


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