public function postAction(Request $request)
    {
        $name = $request->get('name');
        $system = $request->get('system');

        try {
            if (null === $name) {
                throw new InvalidArgumentException('Role', 'name');
            }
            if (null === $system) {
                throw new InvalidArgumentException('Role', 'name');
            }

            $em = $this->getDoctrine()->getManager();

            /** @var RoleInterface $role */
            $role = $this->getRoleRepository()->createNew();
            $role->setName($name);
            $role->setSystem($system);

            $permissions = $request->get('permissions');
            if (!empty($permissions)) {
                foreach ($permissions as $permissionData) {
                    $this->addPermission($role, $permissionData);
                }
            }

            $securityTypeData = $request->get('securityType');
            if ($this->checkSecurityTypeData($securityTypeData)) {
                $this->setSecurityType($role, $securityTypeData);
            }

            try {
                $em->persist($role);
                $em->flush();

                $view = $this->view($this->convertRole($role), 200);
            } catch (DoctrineUniqueConstraintViolationException $ex) {
                throw new SuluUniqueConstraintViolationException('name', 'SuluSecurityBudle:Role');
            }
        } catch (RestException $ex) {
            $view = $this->view($ex->toArray(), 400);
        }

        return $this->handleView($view);
    }