@ POST @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) @ RequiresPermissions ( I18nPermissions . KEY_WRITE ) public Response createKey ( KeyRepresentation keyRepresentation ) throws URISyntaxException { WebAssertions . assertNotNull ( keyRepresentation , THE_KEY_SHOULD_NOT_BE_NULL ) ; WebAssertions . assertNotBlank ( keyRepresentation . getName ( ) , THE_KEY_SHOULD_CONTAINS_A_NAME ) ; WebAssertions . assertNotBlank ( keyRepresentation . getDefaultLocale ( ) , THE_KEY_SHOULD_CONTAINS_A_LOCALE ) ; assertKeyDoNotAlreadyExists ( keyRepresentation ) ; Key key = factory . createKey ( keyRepresentation . getName ( ) ) ; key . setComment ( keyRepresentation . getComment ( ) ) ; addDefaultTranslation ( keyRepresentation , key ) ; keyRepository . add ( key ) ; return Response . created ( new URI ( uriInfo . getRequestUri ( ) + "/" + key . getId ( ) ) ) . entity ( keyFinder . findKeyWithName ( key . getId ( ) ) ) . build ( ) ; }
Inserts a key with the translation in the default language .