diff --git a/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index 94b40e0e06..0c48b37583 100644 --- a/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -56,6 +56,13 @@ **/*.xml + + + src/main/conf + + **/*.xml + + src/main/resources diff --git a/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype.xml b/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype.xml index 5cbd494cb5..92efdea7a6 100644 --- a/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype.xml +++ b/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype.xml @@ -51,6 +51,7 @@ src/main/resources/META-INF/scm/plugin.xml src/main/resources/scm/sample.hello.js + src/main/conf/logging.xml \ No newline at end of file diff --git a/maven/scm-plugin-archetype/src/main/resources/archetype-resources/pom.xml b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/pom.xml index a690c1d0b6..0777568fa0 100644 --- a/maven/scm-plugin-archetype/src/main/resources/archetype-resources/pom.xml +++ b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/pom.xml @@ -7,7 +7,7 @@ scm-plugins sonia.scm.plugins - 1.8 + 1.23 ${groupId} @@ -36,6 +36,21 @@ + + + + + + sonia.scm.maven + scm-maven-plugin + 1.30 + + src/main/conf/logging.xml + + + + + diff --git a/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/conf/logging.xml b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/conf/logging.xml new file mode 100644 index 0000000000..1466604231 --- /dev/null +++ b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/conf/logging.xml @@ -0,0 +1,58 @@ + + + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n + + + + + + + + + + + + + + + + + + diff --git a/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/java/HelloResource.java b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/java/HelloResource.java index a79b6e49fd..b25f2da94e 100644 --- a/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/java/HelloResource.java +++ b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/java/HelloResource.java @@ -34,9 +34,13 @@ package ${package}; //~--- non-JDK imports -------------------------------------------------------- import com.google.inject.Inject; -import com.google.inject.Provider; -import sonia.scm.security.SecurityContext; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.subject.Subject; + +import sonia.scm.SCMContext; +import sonia.scm.SCMContextProvider; +import sonia.scm.security.Role; //~--- JDK imports ------------------------------------------------------------ @@ -45,39 +49,55 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +/** + * Sample RESTful WebService endpoint. + * This sample resource is available at /api/rest/hello + */ @Path("hello") -public class HelloResource { +public class HelloResource +{ /** - * Constructs ... + * Constructs a new HelloResource and injects all required dependencies. * * - * @param securityContextProvider + * @param securityContextProvider SCM-Manager context */ @Inject - public HelloResource(Provider securityContextProvider) + public HelloResource(SCMContextProvider context) { - message = "Hello " - + securityContextProvider.get().getUser().getDisplayName(); + this.context = context; } //~--- get methods ---------------------------------------------------------- /** - * Method description + * Returns a hello message * * - * @return + * @return hello message */ @GET @Produces(MediaType.TEXT_PLAIN) public String getHelloMessage() { - return message; + Subject subject = SecurityUtils.getSubject(); + String username; + + if (subject.hasRole(Role.USER)) + { + username = (String) subject.getPrincipal(); + } + else + { + username = SCMContext.USER_ANONYMOUS; + } + + return "Hello " + username + " from SCM-Manager " + context.getVersion(); } //~--- fields --------------------------------------------------------------- - /** Field description */ - private String message; + /** SCM-Manager context */ + private SCMContextProvider context; } diff --git a/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/scm/plugin.xml b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/scm/plugin.xml index e9adeab416..efae4e8c99 100644 --- a/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/scm/plugin.xml +++ b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/scm/plugin.xml @@ -35,14 +35,8 @@ - ${dollar}{project.groupId} - ${dollar}{project.artifactId} - ${dollar}{project.version} - ${dollar}{project.name} - ${dollar}{project.description}