Package org.apache.sling.jackrabbit.usermanager.impl.post

# Class CreateGroupServlet

java.lang.Object
jakarta.servlet.GenericServlet
org.apache.sling.api.servlets.SlingJakartaSafeMethodsServlet
org.apache.sling.api.servlets.SlingJakartaAllMethodsServlet
org.apache.sling.jackrabbit.usermanager.impl.post.AbstractPostServlet
org.apache.sling.jackrabbit.usermanager.impl.post.AbstractAuthorizablePostServlet
org.apache.sling.jackrabbit.usermanager.impl.post.AbstractGroupPostServlet
org.apache.sling.jackrabbit.usermanager.impl.post.CreateGroupServlet

All Implemented Interfaces:
  `jakarta.servlet.Servlet`, `jakarta.servlet.ServletConfig`, `Serializable`, `CreateGroup`

public class CreateGroupServlet extends AbstractGroupPostServlet implements CreateGroup

Sling Post Servlet implementation for creating a group in the jackrabbit UserManager.

## Rest Service Description

Creates a new group. Maps on to nodes of resourceType `sling/groups` like `/rep:system/rep:userManager/rep:groups` mapped to a resource url `/system/userManager/group`. This servlet responds at `/system/userManager/group.create.html`

### Methods

- POST

### Post Parameters

one of these
  - :name - The value is the exact name to use
  - :name@ValueFrom - The value is the name of another submitted parameter whose value is the exact name to use
  - :nameHint - The value is filtered, trimmed and made unique
  - :nameHint@ValueFrom - The value is the name of another submitted parameter whose value is filtered, trimmed and made unique
  - otherwise - Try the value of any server-side configured "principalNameHints" parameter to treat as a hint that is filtered, trimmed and made unique
*
  Any additional parameters become properties of the group node (optional)

### Response

200
  Success, a redirect is sent to the group resource locator. The redirect comes with HTML describing the status.
500
  Failure, including group already exists. HTML explains the failure.

### Example

`curl -F:name=newGroupA -Fproperty1=value1 http://localhost:8080/system/userManager/group.create.html`

#### Notes

See Also:
  - Serialized Form

## Field Summary

### Fields inherited from class org.apache.sling.jackrabbit.usermanager.impl.post.AbstractAuthorizablePostServlet

`principalNameFilter, principalNameGenerators, PROP_DATE_FORMAT, RP_NODE_NAME_HINT_VALUE_FROM, RP_NODE_NAME_VALUE_FROM, systemUserManagerPaths`

## Constructor Summary

Constructors
Constructor
Description
`CreateGroupServlet()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`activate(Map<String,Object> props)`
`protected void`
`bindPostResponseCreator(org.apache.sling.servlets.post.JakartaPostResponseCreator creator, Map<String,Object> properties)`
Overridden since the @Reference annotation is not inherited from the super method
`protected void`
`bindPrincipalNameFilter(PrincipalNameFilter filter)`
Bind a new principal name filter
`protected void`
`bindPrincipalNameGenerator(PrincipalNameGenerator generator, Map<String,Object> properties)`
Bind a new principal name generator
`org.apache.jackrabbit.api.security.user.Group`
`createGroup(javax.jcr.Session jcrSession, String name, Map<String,?> properties, List<org.apache.sling.servlets.post.Modification> changes)`
Create a new group for the repository
`protected void`
`deactivate()`
`protected void`
`handleOperation(org.apache.sling.api.SlingJakartaHttpServletRequest request, org.apache.sling.servlets.post.JakartaPostResponse response, List<org.apache.sling.servlets.post.Modification> changes)`
Extending Servlet should implement this operation to do the work
`protected void`
`unbindPostResponseCreator(org.apache.sling.servlets.post.JakartaPostResponseCreator creator, Map<String,Object> properties)`
Unbind a post response creator
`protected void`
`unbindPrincipalNameFilter(PrincipalNameFilter filter)`
`protected void`
`unbindPrincipalNameGenerator(PrincipalNameGenerator generator)`

### Methods inherited from class org.apache.sling.jackrabbit.usermanager.impl.post.AbstractGroupPostServlet

`updateGroupMembership`

### Methods inherited from class org.apache.sling.jackrabbit.usermanager.impl.post.AbstractAuthorizablePostServlet

`bindSystemUserManagerPaths, collectContentMap, concatPath, convertToRequestParameterArray, convertToString, convertToStringArray, getOrGeneratePrincipalName, hasItemPathPrefix, processCreate, processDeletes, requireItemPathPrefix, writeContent`

### Methods inherited from class org.apache.sling.jackrabbit.usermanager.impl.post.AbstractPostServlet

`doPost, externalizePath, getItemPath, getRanking, getRedirectUrl, isSetStatus`

### Methods inherited from class org.apache.sling.api.servlets.SlingJakartaAllMethodsServlet

`doDelete, doPut, getAllowedRequestMethods, isMethodValid, mayService`

### Methods inherited from class org.apache.sling.api.servlets.SlingJakartaSafeMethodsServlet

`doGeneric, doGet, doHead, doOptions, doTrace, getServletInfo, handleMethodNotImplemented, service, service`

### Methods inherited from class jakarta.servlet.GenericServlet

`destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.sling.jackrabbit.usermanager.CreateGroup

`createGroup`

## Constructor Details

### CreateGroupServlet

public CreateGroupServlet()

## Method Details

### activate

protected void activate(Map<String,Object> props)

Overrides:
  `activate` in class `AbstractAuthorizablePostServlet`

### deactivate

protected void deactivate()

Overrides:
  `deactivate` in class `AbstractAuthorizablePostServlet`

### bindPrincipalNameGenerator

protected void bindPrincipalNameGenerator(PrincipalNameGenerator generator, Map<String,Object> properties)
Description copied from class: `AbstractAuthorizablePostServlet`
Bind a new principal name generator

Overrides:
  `bindPrincipalNameGenerator` in class `AbstractAuthorizablePostServlet`

### unbindPrincipalNameGenerator

protected void unbindPrincipalNameGenerator(PrincipalNameGenerator generator)

Overrides:
  `unbindPrincipalNameGenerator` in class `AbstractAuthorizablePostServlet`

### bindPrincipalNameFilter

protected void bindPrincipalNameFilter(PrincipalNameFilter filter)
Description copied from class: `AbstractAuthorizablePostServlet`
Bind a new principal name filter

Overrides:
  `bindPrincipalNameFilter` in class `AbstractAuthorizablePostServlet`

### unbindPrincipalNameFilter

protected void unbindPrincipalNameFilter(PrincipalNameFilter filter)

Overrides:
  `unbindPrincipalNameFilter` in class `AbstractAuthorizablePostServlet`

### bindPostResponseCreator

protected void bindPostResponseCreator(org.apache.sling.servlets.post.JakartaPostResponseCreator creator, Map<String,Object> properties)
Overridden since the @Reference annotation is not inherited from the super method

Overrides:
  `bindPostResponseCreator` in class `AbstractPostServlet`
See Also:
  - `AbstractPostServlet.bindPostResponseCreator(org.apache.sling.servlets.post.JakartaPostResponseCreator, java.util.Map)`

### unbindPostResponseCreator

protected void unbindPostResponseCreator(org.apache.sling.servlets.post.JakartaPostResponseCreator creator, Map<String,Object> properties)
Description copied from class: `AbstractPostServlet`
Unbind a post response creator

Overrides:
  `unbindPostResponseCreator` in class `AbstractPostServlet`

### handleOperation

protected void handleOperation(org.apache.sling.api.SlingJakartaHttpServletRequest request, org.apache.sling.servlets.post.JakartaPostResponse response, List<org.apache.sling.servlets.post.Modification> changes) throws javax.jcr.RepositoryException
Description copied from class: `AbstractPostServlet`
Extending Servlet should implement this operation to do the work

Specified by:
  `handleOperation` in class `AbstractPostServlet`
Parameters:
  `request` - the sling http request to process
  `response` - the response
  `changes` - the changes to report
Throws:
  `javax.jcr.RepositoryException` - in case of exceptions during the operation

### createGroup

public org.apache.jackrabbit.api.security.user.Group createGroup(javax.jcr.Session jcrSession, String name, Map<String,?> properties, List<org.apache.sling.servlets.post.Modification> changes) throws javax.jcr.RepositoryException
Description copied from interface: `CreateGroup`
Create a new group for the repository

Specified by:
  `createGroup` in interface `CreateGroup`
Parameters:
  `jcrSession` - the JCR session of the user creating the group
  `name` - The name of the new group. If null or empty, the name is calculated from the supplied properties (per SLING-10902).
  `properties` - Extra properties to update on the group. The entry values should be either a String or String[] (optional)
  `changes` - The list of changes for this operation (optional)
Returns:
  the group that was created
Throws:
  `javax.jcr.RepositoryException` - if group can't be created