org.apache.jackrabbit.JcrConstants Java Examples
The following examples show how to use
org.apache.jackrabbit.JcrConstants.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChildrenDataSourceServlet.java From commerce-cif-connector with Apache License 2.0 | 5 votes |
private static Predicate createFolderPredicate() { return object -> { Resource resource = (Resource) object; return resource.isResourceType("sling:Folder") || resource.isResourceType("sling:OrderedFolder") || resource.isResourceType(JcrConstants.NT_FOLDER); }; }
Example #2
Source File: DeltaVResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
public OptionsResponse getOptionResponse(OptionsInfo optionsInfo) { OptionsResponse oR = null; if (optionsInfo != null) { oR = new OptionsResponse(); // currently only DAV:version-history-collection-set is supported if (optionsInfo.containsElement(DeltaVConstants.XML_VH_COLLECTION_SET, DeltaVConstants.NAMESPACE)) { String[] hrefs = new String[] { getLocatorFromNodePath( "/" + JcrConstants.JCR_SYSTEM + "/" + JcrConstants.JCR_VERSIONSTORAGE).getHref(true) }; oR.addEntry(DeltaVConstants.XML_VH_COLLECTION_SET, DeltaVConstants.NAMESPACE, hrefs); } } return oR; }
Example #3
Source File: CommentServlet.java From publick-sling-blog with Apache License 2.0 | 5 votes |
/** * Return all comments on a GET request in order of newest to oldest. */ @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { final PrintWriter writer = response.getWriter(); response.setCharacterEncoding(CharEncoding.UTF_8); response.setContentType("application/json"); List<Resource> comments = commentService.getComments(request); try { JSONArray jsonArray = new JSONArray(); for (Resource comment : comments) { final JSONObject json = new JSONObject(); final ValueMap properties = comment.getValueMap(); final Resource post = commentService.getParentPost(comment); json.put(PublickConstants.COMMENT_PROPERTY_COMMENT, properties.get(PublickConstants.COMMENT_PROPERTY_COMMENT, String.class)); json.put(JSON_ID, properties.get(JcrConstants.JCR_UUID, String.class)); json.put(JSON_EDITED, properties.get(PublickConstants.COMMENT_PROPERTY_EDITED, false)); json.put(JSON_REPLIES, commentService.numberOfReplies(comment)); json.put(JSON_SPAM, properties.get(PublickConstants.COMMENT_PROPERTY_SPAM, false)); json.put(JSON_POST, new JSONObject() .put(JSON_POST_TEXT, post.getValueMap().get(PublickConstants.COMMENT_PROPERTY_TITLE, String.class)) .put(JSON_POST_LINK, linkRewriter.rewriteLink(post.getPath(), request.getServerName()))); jsonArray.put(json); } response.setStatus(SlingHttpServletResponse.SC_OK); writer.write(jsonArray.toString()); } catch (JSONException e) { LOGGER.error("Could not write JSON", e); response.setStatus(SlingHttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
Example #4
Source File: CommentsView.java From publick-sling-blog with Apache License 2.0 | 5 votes |
/** * Create the comment list by getting the passed in resource's children and collecting * their author, comment, and jcr:created properties. Replies are a recursive call to * this methods with the children of the resource passed in resource. * * @param resource The root comments resource or the first level comment. * @param getReplies True to get the next level of comments. * @return The collection of comments. */ private List<HashMap<String, Object>> getCommentList(Resource resource, boolean getReplies) { List<HashMap<String, Object>> comments = new ArrayList<HashMap<String, Object>>(); if (resource != null && resource.hasChildren()) { Iterator<Resource> iterator = resource.listChildren(); while (iterator.hasNext()) { Resource commentResource = iterator.next(); ValueMap properties = commentResource.adaptTo(ValueMap.class); HashMap<String, Object> commentProperties = new HashMap<String, Object>(); String author = properties.get("author", String.class); String comment = properties.get("comment", String.class); String date = getDate(properties.get(JcrConstants.JCR_CREATED, Date.class), DISPLAY_DATE_FORMAT); boolean display = properties.get("display", false); boolean edited = properties.get("edited", false); boolean spam = properties.get("spam", false); if (StringUtils.isNotBlank(author) && StringUtils.isNotBlank(comment) && StringUtils.isNotBlank(date)) { commentProperties.put("author", display && !spam ? author : "--"); commentProperties.put("comment", display && !spam ? comment : "Comment removed by author."); commentProperties.put("date", date); commentProperties.put("edited", edited); commentProperties.put("path", commentResource.getPath()); if (getReplies) { commentProperties.put("replies", getCommentList(commentResource, false)); } comments.add(commentProperties); count++; } } } return comments; }
Example #5
Source File: BlogView.java From publick-sling-blog with Apache License 2.0 | 5 votes |
/** * Get the blog post properties from the resource. * * @param blog The blog post resource. */ private void getBlog(Resource blog) { if (blog != null) { ValueMap properties = blog.adaptTo(ValueMap.class); title = properties.get("title", String.class); month = properties.get("month", Long.class); year = properties.get("year", Long.class); url = properties.get("url", String.class); visible = Boolean.valueOf(properties.get("visible", false)); keywords = properties.get("keywords", String[].class); content = properties.get("content", String.class); description = properties.get("description", String.class); image = properties.get("image", String.class); if (image != null) { image = resolver.map(image); } Date date = properties.get(JcrConstants.JCR_CREATED, Date.class); publishedDate = getDate(date, PUBLISHED_DATE_FORMAT); displayDate = getDate(date, DISPLAY_DATE_FORMAT); imageRelativePath = image; imageAbsolutePath = getAbsolutePath(image); } }
Example #6
Source File: ResourceMixinUtil.java From APM with Apache License 2.0 | 4 votes |
public static void addMixin(ModifiableValueMap vm, String mixin) { Set<String> mixins = new HashSet<>(Arrays.asList(vm.get(JcrConstants.JCR_MIXINTYPES, new String[0]))); mixins.add(mixin); vm.put(JcrConstants.JCR_MIXINTYPES, mixins.toArray(new String[]{})); }