def validate(self, data):
    appstruct = self.structure.validate(data)
    new_appstruct = {}
    _remove_protected_fields(appstruct)
    new_appstruct['userid'] = self.request.authenticated_userid
    uri = appstruct.pop('uri', '').strip()
    if (not uri):
        raise ValidationError(('uri: ' + _("'uri' is a required property")))
    new_appstruct['target_uri'] = uri
    new_appstruct['text'] = appstruct.pop('text', '')
    new_appstruct['tags'] = appstruct.pop('tags', [])
    new_appstruct['groupid'] = appstruct.pop('group', '__world__')
    new_appstruct['references'] = appstruct.pop('references', [])
    if ('permissions' in appstruct):
        new_appstruct['shared'] = _shared(appstruct.pop('permissions'), new_appstruct['groupid'])
    else:
        new_appstruct['shared'] = False
    if ('target' in appstruct):
        new_appstruct['target_selectors'] = _target_selectors(appstruct.pop('target'))
    if (new_appstruct['references'] and ('groupid' in new_appstruct)):
        del new_appstruct['groupid']
    new_appstruct['document'] = _document(appstruct.pop('document', {}), new_appstruct['target_uri'])
    new_appstruct['extra'] = appstruct
    return new_appstruct
def validate(self, data):
    appstruct = self.structure.validate(data)
    new_appstruct = {}
    _remove_protected_fields(appstruct)
    new_appstruct['userid'] = self.request.authenticated_userid
    uri = appstruct.pop('uri', ).strip()
    if (not uri):
        raise ValidationError(('uri: ' + _("'uri' is a required property")))
    new_appstruct['target_uri'] = uri
    new_appstruct['text'] = appstruct.pop('text', )
    new_appstruct['tags'] = appstruct.pop('tags', [])
    new_appstruct['groupid'] = appstruct.pop('group', '__world__')
    new_appstruct['references'] = appstruct.pop('references', [])
    if ('permissions' in appstruct):
        new_appstruct['shared'] = _shared(appstruct.pop('permissions'), new_appstruct['groupid'])
    else:
        new_appstruct['shared'] = False
    if ('target' in appstruct):
        new_appstruct['target_selectors'] = _target_selectors(appstruct.pop('target'))
    if (new_appstruct['references'] and ('groupid' in new_appstruct)):
        del new_appstruct['groupid']
    new_appstruct['document'] = _document(appstruct.pop('document', {}), new_appstruct['target_uri'])
    new_appstruct['extra'] = appstruct
    return new_appstruct