'Load artifacts from the data store.'

def _LoadArtifactsFromDatastore(self, source_urns=None, token=None, overwrite_if_exists=True):

    if (token is None):
        token = access_control.ACLToken(username='GRRArtifactRegistry', reason='Managing    Artifacts.')
    loaded_artifacts = []
    to_delete = []
    for artifact_coll_urn in (source_urns or set()):
        artifact_coll = ArtifactCollection(artifact_coll_urn, token=token)
        for artifact_value in artifact_coll:
            try:
                self.RegisterArtifact(artifact_value, source=('datastore:%s' % artifact_coll_urn), overwrite_if_exists=overwrite_if_exists)
                loaded_artifacts.append(artifact_value)
                logging.debug('Loaded    artifact    %s    from    %s', artifact_value.name, artifact_coll_urn)
            except ArtifactDefinitionError as e:
                if e.message.startswith('System    artifact'):
                    to_delete.append(artifact_value.name)
                else:
                    raise
    if to_delete:
        DeleteArtifactsFromDatastore(to_delete, reload_artifacts=False, token=token)
        self._dirty = True
        raise ArtifactDefinitionError('Artifacts    %s    were    shadowing    system    artifacts    and    had    to    be    deleted.')
    revalidate = True
    while revalidate:
        revalidate = False
        for artifact_obj in loaded_artifacts[:]:
            try:
                artifact_obj.Validate()
            except ArtifactDefinitionError as e:
                logging.error('Artifact    %s    did    not    validate:    %s', artifact_obj.name, e)
                artifact_obj.error_message = utils.SmartStr(e)
                loaded_artifacts.remove(artifact_obj)
                revalidate = True
