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


Java Node.getProperty方法代碼示例

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


在下文中一共展示了Node.getProperty方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: readFile

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public InputStream readFile(String path,String version) throws Exception{
	if(StringUtils.isNotBlank(version)){
		repositoryInteceptor.readFile(path+":"+version);
		return readVersionFile(path, version);
	}
	repositoryInteceptor.readFile(path);
	Node rootNode=getRootNode();
	int colonPos = path.lastIndexOf(":");
	if (colonPos > -1) {
		version = path.substring(colonPos + 1, path.length());
		path = path.substring(0, colonPos);
		return readFile(path, version);
	}
	path = processPath(path);
	if (!rootNode.hasNode(path)) {
		throw new RuleException("File [" + path + "] not exist.");
	}
	Node fileNode = rootNode.getNode(path);
	Property property = fileNode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	return fileBinary.getStream();
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:24,代碼來源:BaseRepositoryService.java

示例4: loadResourceSecurityConfigs

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public List<UserPermission> loadResourceSecurityConfigs(String companyId) throws Exception{
	List<UserPermission> configs=new ArrayList<UserPermission>();
	String filePath=RESOURCE_SECURITY_CONFIG_FILE+(companyId == null ? "" : companyId);
	Node rootNode=getRootNode();
	Node fileNode = rootNode.getNode(filePath);
	Property property = fileNode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	InputStream inputStream = fileBinary.getStream();
	String content = IOUtils.toString(inputStream, "utf-8");
	inputStream.close();
	Document document = DocumentHelper.parseText(content);
	Element rootElement = document.getRootElement();
	for (Object obj : rootElement.elements()) {
		if (!(obj instanceof Element)) {
			continue;
		}
		Element element = (Element) obj;
		if (!element.getName().equals("user-permission")) {
			continue;
		}
		UserPermission userResource=new UserPermission();
		userResource.setUsername(element.attributeValue("username"));
		userResource.setProjectConfigs(parseProjectConfigs(element));
		configs.add(userResource);
	}
	return configs;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:29,代碼來源:RepositoryServiceImpl.java

示例5: 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

示例6: 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

示例7: readVersionFile

import javax.jcr.Node; //導入方法依賴的package包/類
private InputStream readVersionFile(String path, String version) throws Exception{
	path = processPath(path);
	Node rootNode=getRootNode();
	if (!rootNode.hasNode(path)) {
		throw new RuleException("File [" + path + "] not exist.");
	}
	Node fileNode = rootNode.getNode(path);
	VersionHistory versionHistory = versionManager.getVersionHistory(fileNode.getPath());
	Version v = versionHistory.getVersion(version);
	Node fnode = v.getFrozenNode();
	Property property = fnode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	return fileBinary.getStream();
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:15,代碼來源:BaseRepositoryService.java

示例8: loadClientConfigs

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public List<ClientConfig> loadClientConfigs(String project) throws Exception{
	if(!permissionService.isAdmin()){
		throw new NoPermissionException();
	}
	List<ClientConfig> clients=new ArrayList<ClientConfig>();
	Node rootNode=getRootNode();
	String filePath = processPath(project) + "/" + CLIENT_CONFIG_FILE;
	Node fileNode = rootNode.getNode(filePath);
	Property property = fileNode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	InputStream inputStream = fileBinary.getStream();
	String content = IOUtils.toString(inputStream, "utf-8");
	inputStream.close();
	Document document = DocumentHelper.parseText(content);
	Element rootElement = document.getRootElement();
	for (Object obj : rootElement.elements()) {
		if (!(obj instanceof Element)) {
			continue;
		}
		Element element = (Element) obj;
		if (!element.getName().equals("item")) {
			continue;
		}
		ClientConfig client = new ClientConfig();
		client.setName(element.attributeValue("name"));
		client.setClient(element.attributeValue("client"));
		client.setProject(project);
		clients.add(client);
	}
	return clients;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:33,代碼來源:RepositoryServiceImpl.java

示例9: loadProjectResourcePackages

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public List<ResourcePackage> loadProjectResourcePackages(String project) throws Exception {
	Node rootNode=getRootNode();
	String filePath = processPath(project) + "/" + RES_PACKGE_FILE;
	SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	Node fileNode = rootNode.getNode(filePath);
	Property property = fileNode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	InputStream inputStream = fileBinary.getStream();
	String content = IOUtils.toString(inputStream, "utf-8");
	inputStream.close();
	Document document = DocumentHelper.parseText(content);
	Element rootElement = document.getRootElement();
	List<ResourcePackage> packages = new ArrayList<ResourcePackage>();
	for (Object obj : rootElement.elements()) {
		if (!(obj instanceof Element)) {
			continue;
		}
		Element element = (Element) obj;
		if (!element.getName().equals("res-package")) {
			continue;
		}
		ResourcePackage p = new ResourcePackage();
		String dateStr = element.attributeValue("create_date");
		if (dateStr != null) {
			p.setCreateDate(sd.parse(dateStr));
		}
		p.setId(element.attributeValue("id"));
		p.setName(element.attributeValue("name"));
		p.setProject(project);
		List<ResourceItem> items = new ArrayList<ResourceItem>();
		for (Object o : element.elements()) {
			if (!(o instanceof Element)) {
				continue;
			}
			Element ele = (Element) o;
			if (!ele.getName().equals("res-package-item")) {
				continue;
			}
			ResourceItem item = new ResourceItem();
			item.setName(ele.attributeValue("name"));
			item.setPackageId(p.getId());
			item.setPath(ele.attributeValue("path"));
			item.setVersion(ele.attributeValue("version"));
			items.add(item);
		}
		p.setResourceItems(items);
		packages.add(p);
	}
	return packages;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:52,代碼來源:BaseRepositoryService.java


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