You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2016/03/15 08:54:09 UTC
svn commit: r1735028 - in
/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot:
StreamInfo.java User.java UserInfo.java
comments/impl/CommentPostServlet.java impl/SetupService.java
ratings/impl/RatingPostServlet.java
Author: cziegeler
Date: Tue Mar 15 07:54:09 2016
New Revision: 1735028
URL: http://svn.apache.org/viewvc?rev=1735028&view=rev
Log:
Rework sample app and update UI
Added:
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/StreamInfo.java (with props)
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/User.java (with props)
sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/UserInfo.java (with props)
Modified:
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/java/org/apache/sling/sample/slingshot/ratings/impl/RatingPostServlet.java
Added: sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/StreamInfo.java
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/StreamInfo.java?rev=1735028&view=auto
==============================================================================
--- sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/StreamInfo.java (added)
+++ sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/StreamInfo.java Tue Mar 15 07:54:09 2016
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+
+public abstract class StreamInfo {
+
+ /** The resource type for a stream info. */
+ public static final String RESOURCETYPE = "slingshot/Streaminfo";
+
+ public static final String PROPERTY_TITLE = "title";
+
+ public static final String PROPERTY_DESCRIPTION = "description";
+
+ public static final String PATH_PHOTO = "photo";
+}
Propchange: sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/StreamInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/StreamInfo.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added: sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/User.java
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/User.java?rev=1735028&view=auto
==============================================================================
--- sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/User.java (added)
+++ sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/User.java Tue Mar 15 07:54:09 2016
@@ -0,0 +1,25 @@
+/*
+ * 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;
+
+
+public abstract class User {
+
+ /** The resource type for a user. */
+ public static final String RESOURCETYPE = "slingshot/User";
+
+}
Propchange: sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/User.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/User.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added: sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/UserInfo.java
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/UserInfo.java?rev=1735028&view=auto
==============================================================================
--- sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/UserInfo.java (added)
+++ sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/UserInfo.java Tue Mar 15 07:54:09 2016
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+
+public abstract class UserInfo {
+
+ /** The resource type for a user info. */
+ public static final String RESOURCETYPE = "slingshot/Userinfo";
+
+ public static final String PROPERTY_NAME = "name";
+
+ public static final String PROPERTY_ABOUT = "about";
+
+ public static final String PATH_PHOTO = "photo";
+}
Propchange: sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/UserInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/UserInfo.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
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=1735028&r1=1735027&r2=1735028&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 Tue Mar 15 07:54:09 2016
@@ -17,8 +17,6 @@
package org.apache.sling.sample.slingshot.comments.impl;
import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
import javax.servlet.ServletException;
@@ -35,7 +33,6 @@ import org.apache.sling.sample.slingshot
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.InternalConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,12 +64,7 @@ public class CommentPostServlet extends
// save comment
ResourceResolver resolver = null;
try {
- // TODO - switch to service user with Oak
- final Map<String, Object> authInfo = new HashMap<String, Object>();
- authInfo.put(ResourceResolverFactory.USER, InternalConstants.SERVICE_USER_NAME);
- authInfo.put(ResourceResolverFactory.PASSWORD, InternalConstants.SERVICE_USER_NAME.toCharArray());
- resolver = factory.getResourceResolver(authInfo);
-// resolver = factory.getServiceResourceResolver(null);
+ resolver = factory.getServiceResourceResolver(null);
final Resource reqResource = resolver.getResource(request.getResource().getPath());
@@ -82,12 +74,12 @@ public class CommentPostServlet extends
c.setCreatedBy(userId);
this.commentsService.addComment(reqResource, c);
-
+
// send redirect at the end
final String path = request.getResource().getPath();
- response.sendRedirect(resolver.map(request.getContextPath() + path + ".html"));
+ response.sendRedirect(resolver.map(request.getContextPath() + path + ".html"));
} catch ( final LoginException le ) {
throw new ServletException("Unable to login", le);
} finally {
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=1735028&r1=1735027&r2=1735028&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 Tue Mar 15 07:54:09 2016
@@ -133,23 +133,23 @@ public class SetupService {
}
private void setupUsers(final BundleContext bc, final ResourceResolver resolver) throws RepositoryException, IOException {
- final UserManager um = AccessControlUtil.getUserManager(resolver.adaptTo(Session.class));
+ final Session session = resolver.adaptTo(Session.class);
+ final UserManager um = AccessControlUtil.getUserManager(session);
for(final String userName : USERS) {
Authorizable user = um.getAuthorizable(userName);
if ( user == null ) {
logger.info("Creating user {}", userName);
um.createUser(userName, userName);
+ session.save();
}
}
// create a service user
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);
+ logger.info("Creating service user {}", InternalConstants.SERVICE_USER_NAME);
+ um.createSystemUser(InternalConstants.SERVICE_USER_NAME, null);
+ session.save();
}
// check for service user config
Modified: sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/ratings/impl/RatingPostServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/ratings/impl/RatingPostServlet.java?rev=1735028&r1=1735027&r2=1735028&view=diff
==============================================================================
--- sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/ratings/impl/RatingPostServlet.java (original)
+++ sling/trunk/samples/slingshot/src/main/java/org/apache/sling/sample/slingshot/ratings/impl/RatingPostServlet.java Tue Mar 15 07:54:09 2016
@@ -18,8 +18,6 @@ package org.apache.sling.sample.slingsho
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.Map;
import javax.servlet.ServletException;
@@ -33,7 +31,6 @@ import org.apache.sling.api.resource.Res
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.apache.sling.sample.slingshot.SlingshotConstants;
-import org.apache.sling.sample.slingshot.impl.InternalConstants;
import org.apache.sling.sample.slingshot.ratings.RatingsService;
import org.apache.sling.sample.slingshot.ratings.RatingsUtil;
import org.slf4j.Logger;
@@ -68,12 +65,7 @@ public class RatingPostServlet extends S
// save rating
ResourceResolver resolver = null;
try {
- // TODO - switch to service user with Oak
- final Map<String, Object> authInfo = new HashMap<String, Object>();
- authInfo.put(ResourceResolverFactory.USER, InternalConstants.SERVICE_USER_NAME);
- authInfo.put(ResourceResolverFactory.PASSWORD, InternalConstants.SERVICE_USER_NAME.toCharArray());
- resolver = factory.getResourceResolver(authInfo);
-// resolver = factory.getServiceResourceResolver(null);
+ resolver = factory.getServiceResourceResolver(null);
final Resource reqResource = resolver.getResource(request.getResource().getPath());