当前位置: 首页>>代码示例>>Java>>正文


Java JcrResourceUtil类代码示例

本文整理汇总了Java中org.apache.sling.jcr.resource.JcrResourceUtil的典型用法代码示例。如果您正苦于以下问题:Java JcrResourceUtil类的具体用法?Java JcrResourceUtil怎么用?Java JcrResourceUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JcrResourceUtil类属于org.apache.sling.jcr.resource包,在下文中一共展示了JcrResourceUtil类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteComment

import org.apache.sling.jcr.resource.JcrResourceUtil; //导入依赖的package包/类
/**
 * Delete comment by setting it's display property to false.
 *
 * @param request The current request to get session and Resource Resolver
 * @param id The comment UUID
 * @return true if the operation was successful
 */
public boolean deleteComment(final SlingHttpServletRequest request, final String id) {
    boolean result = false;

    try {
        Session session = request.getResourceResolver().adaptTo(Session.class); 
        Node node = session.getNodeByIdentifier(id);

        if (node != null) {
            JcrResourceUtil.setProperty(node, PublickConstants.COMMENT_PROPERTY_DISPLAY, false);
            session.save();
            result = true;
        }
    } catch (RepositoryException e) {
        LOGGER.error("Could not delete comment from JCR", e);
    }

    return result;
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:26,代码来源:CommentServiceImpl.java

示例2: editComment

import org.apache.sling.jcr.resource.JcrResourceUtil; //导入依赖的package包/类
/**
 * Edit comment and mark it as author edited.
 *
 * @param request The current request to get session and Resource Resolver
 * @param id The comment UUID
 * @param text The comment text
 * @return true if the operation was successful
 */
public boolean editComment(final SlingHttpServletRequest request, final String id, String text) {
    boolean result = false;

    try {
        Session session = request.getResourceResolver().adaptTo(Session.class);
        Node node = session.getNodeByIdentifier(id);

        if (node != null) {
            JcrResourceUtil.setProperty(node, PublickConstants.COMMENT_PROPERTY_COMMENT, text);
            JcrResourceUtil.setProperty(node, PublickConstants.COMMENT_PROPERTY_EDITED, true);
            session.save();
            result = true;
        }
    } catch (RepositoryException e) {
        LOGGER.error("Could not update comment from JCR", e);
    }

    return result;
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:28,代码来源:CommentServiceImpl.java

示例3: valuesToJavaObject

import org.apache.sling.jcr.resource.JcrResourceUtil; //导入依赖的package包/类
protected Object valuesToJavaObject(Value[] values)
        throws RepositoryException {
    if (values == null) {
        return null;
    } else if (values.length == 1) {
        return JcrResourceUtil.toJavaObject(values[0]);
    } else {
        Object[] valuesObjs = new Object[values.length];
        for (int i = 0; i < values.length; i++) {
            valuesObjs[i] = JcrResourceUtil.toJavaObject(values[i]);
        }
        return valuesObjs;
    }
}
 
开发者ID:hlta,项目名称:playweb,代码行数:15,代码来源:EntityValueMap.java


注:本文中的org.apache.sling.jcr.resource.JcrResourceUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。