Author: cziegeler
Date: Mon May 11 19:50:49 2015
New Revision: 1678808
URL: http://svn.apache.org/r1678808
Log:
Implements simple Comments service
Added:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/CommentsService.java
(with props)
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/impl/CommentsServiceImpl.java
(with props)
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/package-info.java
(with props)
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/ratings/package-info.java
(with props)
Modified:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/Comment.java
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/CommentsUtil.java
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/impl/CommentPostServlet.java
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/impl/SetupService.java
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Comment/item.html.jsp
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Home/html.jsp
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Item/comments.html.jsp
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Item/edit.html.jsp
Modified:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/Comment.java
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/Comment.java?rev=1678808&r1=1678807&r2=1678808&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/Comment.java
(original)
+++
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/Comment.java
Mon May 11 19:50:49 2015
@@ -18,13 +18,46 @@ package org.apache.sling.sample.slingsho
import java.util.Calendar;
-public interface Comment {
+public class Comment {
- String getTitle();
+ private String title;
- String getDescription();
+ private String text;
- Calendar getCreated();
+ private Calendar created;
+
+ private String createdBy;
+
+ public String getTitle() {
+ return this.title;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public Calendar getCreated() {
+ return created;
+ }
+
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+ public void setTitle(final String title) {
+ this.title = title;
+ }
+
+ public void setText(final String text) {
+ this.text = text;
+ }
+
+ public void setCreated(final Calendar created) {
+ this.created = created;
+ }
+
+ public void setCreatedBy(final String createdBy) {
+ this.createdBy = createdBy;
+ }
- String getCreatedBy();
}
Added:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/CommentsService.java
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/CommentsService.java?rev=1678808&view=auto
==============================================================================
---
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/CommentsService.java
(added)
+++
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/CommentsService.java
Mon May 11 19:50:49 2015
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.sample.slingshot.comments;
+
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+
+/**
+ * Service for handling the comments
+ */
+public interface CommentsService {
+
+ /**
+ * Return the path to the comments resource for a resource.
+ * @param resource The content resource, this is usually an item.
+ * @return The path to the comments resource or {@code null} if
+ * the passed in content resource is not part of
+ * Slingshot.
+ */
+ String getCommentsResourcePath(final Resource resource);
+
+ void addComment(final Resource resource, final Comment c)
+ throws PersistenceException;
+}
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/CommentsService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/CommentsService.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/CommentsService.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/CommentsUtil.java
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/CommentsUtil.java?rev=1678808&r1=1678807&r2=1678808&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/CommentsUtil.java
(original)
+++
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/CommentsUtil.java
Mon May 11 19:50:49 2015
@@ -24,7 +24,7 @@ public abstract class CommentsUtil {
public static final String PROPERTY_TITLE = "title";
- public static final String PROPERTY_DESCRIPTION = "description";
+ public static final String PROPERTY_TEXT = "text";
public static final String PROPERTY_USER = "user";
Modified:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/impl/CommentPostServlet.java
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/impl/CommentPostServlet.java?rev=1678808&r1=1678807&r2=1678808&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/impl/CommentPostServlet.java
(original)
+++
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/impl/CommentPostServlet.java
Mon May 11 19:50:49 2015
@@ -17,11 +17,7 @@
package org.apache.sling.sample.slingshot.comments.impl;
import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
import javax.servlet.ServletException;
import org.apache.felix.scr.annotations.Reference;
@@ -29,15 +25,14 @@ import org.apache.felix.scr.annotations.
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.LoginException;
-import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
-import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.apache.sling.sample.slingshot.SlingshotConstants;
+import org.apache.sling.sample.slingshot.comments.Comment;
+import org.apache.sling.sample.slingshot.comments.CommentsService;
import org.apache.sling.sample.slingshot.comments.CommentsUtil;
-import org.apache.sling.sample.slingshot.impl.Util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,65 +46,34 @@ public class CommentPostServlet extends
@Reference
private ResourceResolverFactory factory;
+ @Reference
+ private CommentsService commentsService;
+
@Override
protected void doPost(final SlingHttpServletRequest request,
final SlingHttpServletResponse response)
throws ServletException, IOException {
- final String title =
request.getParameter(SlingshotConstants.PROPERTY_TITLE);
- final String description =
request.getParameter(SlingshotConstants.PROPERTY_DESCRIPTION);
+ final String title = request.getParameter(CommentsUtil.PROPERTY_TITLE);
+ final String text = request.getParameter(CommentsUtil.PROPERTY_TEXT);
final String userId = request.getRemoteUser();
- logger.debug("New comment from {} : {} - {}", new Object[] {userId,
title, description});
+ logger.debug("New comment from {} : {} - {}", new Object[] {userId,
title, text});
// TODO - check values
// save comment
ResourceResolver resolver = null;
try {
- resolver = factory.getAdministrativeResourceResolver(null);
+ resolver = factory.getServiceResourceResolver(null);
final Resource reqResource =
resolver.getResource(request.getResource().getPath());
- final Map<String, Object> properties = new HashMap<String,
Object>();
- properties.put(ResourceResolver.PROPERTY_RESOURCE_TYPE,
CommentsUtil.RESOURCETYPE_COMMENT);
- properties.put(SlingshotConstants.PROPERTY_TITLE, title);
- properties.put(SlingshotConstants.PROPERTY_DESCRIPTION,
description);
- properties.put(CommentsUtil.PROPERTY_USER, userId);
-
- // we try it five times
- PersistenceException exception = null;
- Resource newResource = null;
- for(int i=0; i<5; i++) {
- try {
- exception = null;
- final String name =
ResourceUtil.createUniqueChildName(reqResource, Util.filter(title));
- newResource = resolver.create(reqResource, name,
properties);
-
- resolver.commit();
- break;
- } catch ( final PersistenceException pe) {
- resolver.revert();
- resolver.refresh();
- exception = pe;
- }
- }
- if ( exception != null ) {
- throw exception;
- }
- // order node at the top (if jcr based)
- final Node newNode = newResource.adaptTo(Node.class);
- if ( newNode != null ) {
- try {
- final Node parent = newNode.getParent();
- final Node firstNode = parent.getNodes().nextNode();
- if ( !firstNode.getName().equals(newNode.getName()) ) {
- parent.orderBefore(newNode.getName(),
firstNode.getName());
- newNode.getSession().save();
- }
- } catch ( final RepositoryException re) {
- logger.error("Unable to order comment to the top", re);
- }
- }
+ final Comment c = new Comment();
+ c.setTitle(title);
+ c.setText(text);
+ c.setCreatedBy(userId);
+
+ this.commentsService.addComment(reqResource, c);
} catch ( final LoginException le ) {
throw new ServletException("Unable to login", le);
} finally {
Added:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/impl/CommentsServiceImpl.java
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/impl/CommentsServiceImpl.java?rev=1678808&view=auto
==============================================================================
---
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/impl/CommentsServiceImpl.java
(added)
+++
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/impl/CommentsServiceImpl.java
Mon May 11 19:50:49 2015
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.sample.slingshot.comments.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.sample.slingshot.SlingshotConstants;
+import org.apache.sling.sample.slingshot.SlingshotUtil;
+import org.apache.sling.sample.slingshot.comments.Comment;
+import org.apache.sling.sample.slingshot.comments.CommentsService;
+import org.apache.sling.sample.slingshot.comments.CommentsUtil;
+import org.apache.sling.sample.slingshot.impl.Util;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implementation of the comments service
+ */
+@Component
+@Service(value=CommentsService.class)
+public class CommentsServiceImpl implements CommentsService {
+
+ /** The resource type for the comments holder. */
+ public static final String RESOURCETYPE_COMMENTS = "sling:OrderedFolder";
+
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ /**
+ * @see
org.apache.sling.sample.slingshot.comments.CommentsService#getCommentsResourcePath(org.apache.sling.api.resource.Resource)
+ */
+ public String getCommentsResourcePath(final Resource resource) {
+ final String contentPath = SlingshotUtil.getContentPath(resource);
+ if ( contentPath != null ) {
+ final String fullPath = SlingshotConstants.APP_ROOT_PATH
+ + "/users/" + SlingshotUtil.getUserId(resource)
+ + "/ugc/comments" + contentPath;
+ return fullPath;
+ }
+ return null;
+ }
+
+ /**
+ * @see
org.apache.sling.sample.slingshot.comments.CommentsService#addComment(org.apache.sling.api.resource.Resource,
org.apache.sling.sample.slingshot.comments.Comment)
+ */
+ public void addComment(final Resource resource, final Comment c)
+ throws PersistenceException {
+ final String commentsPath = this.getCommentsResourcePath(resource);
+ final Map<String, Object> props = new HashMap<String, Object>();
+ props.put(ResourceResolver.PROPERTY_RESOURCE_TYPE,
RESOURCETYPE_COMMENTS);
+ final Resource ratingsResource =
ResourceUtil.getOrCreateResource(resource.getResourceResolver(),
+ commentsPath, props, null, true);
+
+ final Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(ResourceResolver.PROPERTY_RESOURCE_TYPE,
CommentsUtil.RESOURCETYPE_COMMENT);
+ properties.put(CommentsUtil.PROPERTY_TITLE, c.getTitle());
+ properties.put(CommentsUtil.PROPERTY_TEXT, c.getTitle());
+ properties.put(CommentsUtil.PROPERTY_USER, c.getCreatedBy());
+
+ // we try it five times
+ PersistenceException exception = null;
+ Resource newResource = null;
+ for(int i=0; i<5; i++) {
+ try {
+ exception = null;
+ final String name =
ResourceUtil.createUniqueChildName(ratingsResource, Util.filter(c.getTitle()));
+ newResource =
resource.getResourceResolver().create(ratingsResource, name, properties);
+
+ resource.getResourceResolver().commit();
+ break;
+ } catch ( final PersistenceException pe) {
+ resource.getResourceResolver().revert();
+ resource.getResourceResolver().refresh();
+ exception = pe;
+ }
+ }
+ if ( exception != null ) {
+ throw exception;
+ }
+ // order node at the top (if jcr based)
+ final Node newNode = newResource.adaptTo(Node.class);
+ if ( newNode != null ) {
+ try {
+ final Node parent = newNode.getParent();
+ final Node firstNode = parent.getNodes().nextNode();
+ if ( !firstNode.getName().equals(newNode.getName()) ) {
+ parent.orderBefore(newNode.getName(), firstNode.getName());
+ newNode.getSession().save();
+ }
+ } catch ( final RepositoryException re) {
+ logger.error("Unable to order comment to the top", re);
+ }
+ }
+ }
+
+}
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/impl/CommentsServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/impl/CommentsServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/impl/CommentsServiceImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/package-info.java
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/package-info.java?rev=1678808&view=auto
==============================================================================
---
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/package-info.java
(added)
+++
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/package-info.java
Mon May 11 19:50:49 2015
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+@Version("1.0")
+package org.apache.sling.sample.slingshot.comments;
+
+import aQute.bnd.annotation.Version;
+
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/package-info.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/comments/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/impl/SetupService.java
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/impl/SetupService.java?rev=1678808&r1=1678807&r2=1678808&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/impl/SetupService.java
(original)
+++
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/impl/SetupService.java
Mon May 11 19:50:49 2015
@@ -152,16 +152,20 @@ public class SetupService {
Authorizable user =
um.getAuthorizable(InternalConstants.SERVICE_USER_NAME);
if ( user == null ) {
logger.info("Creating user {}",
InternalConstants.SERVICE_USER_NAME);
+ // TODO - jackrabbit 2 does not support creating a system user
+ // um.createSystemUser(InternalConstants.SERVICE_USER_NAME, null);
+
um.createUser(InternalConstants.SERVICE_USER_NAME,
InternalConstants.SERVICE_USER_NAME);
}
// check for service user config
boolean exists = false;
try {
- if ( this.configAdmin.listConfigurations("(&("
+ final Configuration[] configs =
this.configAdmin.listConfigurations("(&("
+ ConfigurationAdmin.SERVICE_FACTORYPID +
"=org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended"
+ ")(user.mapping=" + bc.getBundle().getSymbolicName() +
"*"
- + "))") != null ) {
+ + "))");
+ if ( configs != null && configs.length > 0 ) {
exists = true;
}
} catch (final InvalidSyntaxException e) {
Added:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/ratings/package-info.java
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/ratings/package-info.java?rev=1678808&view=auto
==============================================================================
---
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/ratings/package-info.java
(added)
+++
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/ratings/package-info.java
Mon May 11 19:50:49 2015
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+@Version("1.0")
+package org.apache.sling.sample.slingshot.ratings;
+
+import aQute.bnd.annotation.Version;
+
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/ratings/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/ratings/package-info.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/ratings/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Comment/item.html.jsp
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Comment/item.html.jsp?rev=1678808&r1=1678807&r2=1678808&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Comment/item.html.jsp
(original)
+++
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Comment/item.html.jsp
Mon May 11 19:50:49 2015
@@ -19,18 +19,18 @@
%><%@page import="org.apache.sling.api.resource.Resource,
org.apache.sling.api.resource.ResourceUtil,
org.apache.sling.api.resource.ValueMap,
- org.apache.sling.sample.slingshot.SlingshotConstants,
+ org.apache.sling.sample.slingshot.comments.CommentsUtil,
org.apache.sling.api.request.ResponseUtil" %><%
%><%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %><%
%><sling:defineObjects/><%
%><div class="comment">
<%
final ValueMap attr = resource.getValueMap();
- final String title = attr.get(SlingshotConstants.PROPERTY_TITLE,
resource.getName());
- final String description =
attr.get(SlingshotConstants.PROPERTY_DESCRIPTION, "");
- final String userId = attr.get(SlingshotConstants.PROPERTY_USER, "");
+ final String title = attr.get(CommentsUtil.PROPERTY_TITLE,
resource.getName());
+ final String text = attr.get(CommentsUtil.PROPERTY_TEXT, "");
+ final String userId = attr.get(CommentsUtil.PROPERTY_USER, "");
%>
<h4><%= ResponseUtil.escapeXml(userId) %> : <%=
ResponseUtil.escapeXml(title) %></h4>
- <p><%= ResponseUtil.escapeXml(description) %></p>
- <p><%=
ResponseUtil.escapeXml(attr.get(SlingshotConstants.PROPERTY_CREATED, "")) %></p>
+ <p><%= ResponseUtil.escapeXml(text) %></p>
+ <p><%= ResponseUtil.escapeXml(attr.get(CommentsUtil.PROPERTY_CREATED, ""))
%></p>
</div>
Modified:
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Home/html.jsp
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Home/html.jsp?rev=1678808&r1=1678807&r2=1678808&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Home/html.jsp
(original)
+++
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Home/html.jsp
Mon May 11 19:50:49 2015
@@ -41,7 +41,7 @@
</div>
<div class="ui-widget-content">
<p>Welcome back, <%= request.getRemoteUser() %></p>
- <p><a href="<%= request.getContextPath() %><%=
SlingshotConstants.APP_ROOT_PATH %>/public/<%= request.getRemoteUser()
%>.html">Go to your SlingShot home page</a></p>
+ <p><a href="<%= request.getContextPath() %><%=
SlingshotConstants.APP_ROOT_PATH %>/users/<%= request.getRemoteUser()
%>.html">Go to your SlingShot home page</a></p>
</div>
</div>
<%
Modified:
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Item/comments.html.jsp
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Item/comments.html.jsp?rev=1678808&r1=1678807&r2=1678808&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Item/comments.html.jsp
(original)
+++
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Item/comments.html.jsp
Mon May 11 19:50:49 2015
@@ -19,14 +19,16 @@
%><%@page import="org.apache.sling.api.resource.Resource,
org.apache.sling.api.resource.ResourceUtil,
org.apache.sling.api.resource.ValueMap,
- org.apache.sling.sample.slingshot.SlingshotConstants,
+ org.apache.sling.sample.slingshot.comments.CommentsService,
+ org.apache.sling.sample.slingshot.comments.CommentsUtil,
org.apache.sling.api.request.ResponseUtil" %><%
%><%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %><%
%><sling:defineObjects/><%
%><div class="ui-slingshot-comments">
<h3>Comments</h3>
<%
- final Resource parent = resource.getChild("comments");
+ final CommentsService commentsService =
sling.getService(CommentsService.class);
+ final Resource parent =
resource.getResourceResolver().getResource(commentsService.getCommentsResourcePath(resource));
if ( parent == null ) {
%><p>No comments...</p><%
} else {
@@ -42,9 +44,10 @@
if ( slingRequest.getAuthType() != null ) {
%>
<hr/><p>Leave a comment...</p>
- <form method="POST" action="<%= request.getContextPath()
%><%=resource.getName() %>/comments">
- <p>Title: <input name="<%= SlingshotConstants.PROPERTY_TITLE %>"/></p>
- <p>Description: <input name="<%=
SlingshotConstants.PROPERTY_DESCRIPTION %>"/></p>
+ <form method="POST" action="<%= request.getContextPath()
%><%=resource.getName() %>.comments">
+ <input type="hidden" name=":redirect" value="<%=
request.getContextPath() %><%=resource.getPath() %>.html"/>
+ <p>Title: <input name="<%= CommentsUtil.PROPERTY_TITLE %>"/></p>
+ <p>Text: <input name="<%= CommentsUtil.PROPERTY_TEXT %>"/></p>
<button class="ui-button ui-form-button" type="submit">Add</button>
</form>
<%
Modified:
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Item/edit.html.jsp
URL:
http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Item/edit.html.jsp?rev=1678808&r1=1678807&r2=1678808&view=diff
==============================================================================
---
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Item/edit.html.jsp
(original)
+++
sling/trunk/samples/slingshot/src/main/resources/SLING-INF/content/libs/slingshot/Item/edit.html.jsp
Mon May 11 19:50:49 2015
@@ -44,12 +44,12 @@
<h1><%= title %></h1>
<img src="<%= request.getContextPath() %><%= imagePath %>"/>
<form method="POST" action="<%= request.getContextPath()
%><%=resource.getName() %>">
- <input type="hidden" name=":redirect" value="<%=
request.getContextPath() %><%=resource.getName() %>.html"/>
+ <input type="hidden" name=":redirect" value="<%=
request.getContextPath() %><%=resource.getPath() %>.html"/>
<p>Title: <input name="<%= SlingshotConstants.PROPERTY_TITLE %>"
value="<%= title %>"/></p>
<p>Description: <input name="<%= SlingshotConstants.PROPERTY_DESCRIPTION
%>"
value="<%=ResponseUtil.escapeXml(attributes.get(SlingshotConstants.PROPERTY_DESCRIPTION,
""))%>"/></p>
<p>Location: <input name="<%= SlingshotConstants.PROPERTY_LOCATION %>"
value="<%=ResponseUtil.escapeXml(attributes.get(SlingshotConstants.PROPERTY_LOCATION,
""))%>"/></p>
<button class="ui-button ui-form-button" type="submit">Save</button>
- <p><a href="<%= request.getContextPath() %><%=resource.getName()
%>.html">Cancel</a></p>
+ <p><a href="<%= request.getContextPath() %><%=resource.getPath()
%>.html">Cancel</a></p>
</form>
</body>
</html>
\ No newline at end of file