@PUT
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @Path("/{namespaceId}")
    @Description("Update the namespace.")
    public NamespaceDto updateNamespace(@Context HttpServletRequest req,
        @PathParam("namespaceId") final BigInteger namespaceId, NamespaceDto newNamespace) {
        PrincipalUser remoteUser = getRemoteUser(req);

        if (namespaceId == null || namespaceId.compareTo(BigInteger.ZERO) < 1) {
            throw new WebApplicationException("Namespace Id cannot be null and must be a positive non-zero number.", Status.BAD_REQUEST);
        }
        if (newNamespace == null) {
            throw new WebApplicationException("Cannot update null namespace.", Status.BAD_REQUEST);
        }

        Namespace oldNamespace = _namespaceService.findNamespaceByPrimaryKey(namespaceId);

        if (oldNamespace == null) {
            throw new WebApplicationException("The namespace with id " + namespaceId + " does not exist", Response.Status.NOT_FOUND);
        }
        if (!oldNamespace.getQualifier().equals(newNamespace.getQualifier())) {
            throw new WebApplicationException("The qualifier can not be updated.", Response.Status.NOT_FOUND);
        }
        validateResourceAuthorization(req, oldNamespace.getCreatedBy(), remoteUser);

        Set<PrincipalUser> users = _getPrincipalUserByUserName(newNamespace.getUsernames());

        if (!users.contains(oldNamespace.getOwner())) {
            users.add(oldNamespace.getOwner());
        }
        oldNamespace.setUsers(users);
        return NamespaceDto.transformToDto(_namespaceService.updateNamespace(oldNamespace));
    }
@ PUT @ Produces ( MediaType . APPLICATION_JSON ) @ Consumes ( MediaType . APPLICATION_JSON ) @ Path ( "/{namespaceId}" ) @ Description ( "Update the namespace." ) public NamespaceDto updateNamespace ( @ Context HttpServletRequest req , @ PathParam ( "namespaceId" ) final BigInteger namespaceId , NamespaceDto newNamespace ) { PrincipalUser remoteUser = getRemoteUser ( req ) ; if ( namespaceId == null || namespaceId . compareTo ( BigInteger . ZERO ) < 1 ) { throw new WebApplicationException ( "Namespace Id cannot be null and must be a positive non-zero number." , Status . BAD_REQUEST ) ; } if ( newNamespace == null ) { throw new WebApplicationException ( "Cannot update null namespace." , Status . BAD_REQUEST ) ; } Namespace oldNamespace = _namespaceService . findNamespaceByPrimaryKey ( namespaceId ) ; if ( oldNamespace == null ) { throw new WebApplicationException ( "The namespace with id " + namespaceId + " does not exist" , Response . Status . NOT_FOUND ) ; } if ( ! oldNamespace . getQualifier ( ) . equals ( newNamespace . getQualifier ( ) ) ) { throw new WebApplicationException ( "The qualifier can not be updated." , Response . Status . NOT_FOUND ) ; } validateResourceAuthorization ( req , oldNamespace . getCreatedBy ( ) , remoteUser ) ; Set < PrincipalUser > users = _getPrincipalUserByUserName ( newNamespace . getUsernames ( ) ) ; if ( ! users . contains ( oldNamespace . getOwner ( ) ) ) { users . add ( oldNamespace . getOwner ( ) ) ; } oldNamespace . setUsers ( users ) ; return NamespaceDto . transformToDto ( _namespaceService . updateNamespace ( oldNamespace ) ) ; }
Updates a namespace.

@param   req           The HTTP request.
@param   namespaceId   The ID of the namespace to update.
@param   newNamespace  The updated namespace data.

@return  The updated namespace.

@throws  WebApplicationException  If an error occurs.