本文整理汇总了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;
}
示例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;
}
示例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;
}
}