Example usage for org.springframework.security.core.context SecurityContextHolder setContext

List of usage examples for org.springframework.security.core.context SecurityContextHolder setContext

Introduction

In this page you can find the example usage for org.springframework.security.core.context SecurityContextHolder setContext.

Prototype

public static void setContext(SecurityContext context) 

Source Link

Document

Associates a new SecurityContext with the current thread of execution.

Usage

From source file:ubic.gemma.loader.expression.arrayDesign.ArrayDesignProbeMapperServiceImpl.java

/**
 * @param queue/* w ww . j  a va2 s .c om*/
 * @param generatorDone
 * @param loaderDone
 */
private void load(final BlockingQueue<BlatAssociation> queue, final AtomicBoolean generatorDone,
        final AtomicBoolean loaderDone) {
    final SecurityContext context = SecurityContextHolder.getContext();
    assert context != null;

    Thread loadThread = new Thread(new Runnable() {
        @Override
        public void run() {
            SecurityContextHolder.setContext(context);
            doLoad(queue, generatorDone, loaderDone);
        }

    }, "PersistBlatAssociations");

    loadThread.start();

}

From source file:ubic.gemma.loader.genome.gene.ncbi.NcbiGeneLoader.java

/**
 * @param geneQueue a blocking queue of genes to be loaded into the database loads genes into the database
 * @param geneQueue//from   ww w.  jav  a  2 s .co  m
 */
private void load(final BlockingQueue<Gene> geneQueue) {
    final SecurityContext context = SecurityContextHolder.getContext();
    assert context != null;

    Thread loadThread = new Thread(new Runnable() {
        @Override
        public void run() {
            SecurityContextHolder.setContext(context);
            doLoad(geneQueue);
        }

    }, "Loading");
    loadThread.start();

    while (!generatorDone.get() || !converterDone.get() || !loaderDone.get()) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

From source file:ubic.gemma.loader.genome.goldenpath.GoldenPathBioSequenceLoader.java

/**
 * @param inputStream/*from   ww w . j a v  a2 s.  c o  m*/
 * @return
 * @throws IOException
 */
public void load(final InputStream inputStream) {

    final BlockingQueue<BioSequence> queue = new ArrayBlockingQueue<BioSequence>(QUEUE_SIZE);
    final SecurityContext context = SecurityContextHolder.getContext();

    Thread loadThread = new Thread(new Runnable() {
        @Override
        public void run() {
            log.info("Starting loading");
            SecurityContextHolder.setContext(context);
            load(queue);
        }
    });

    loadThread.start();

    Thread parseThread = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                parser.parse(inputStream, queue);
            } catch (IOException e) {
                e.printStackTrace();
            }
            log.info("Done parsing");
            producerDone = true;
        }
    });

    parseThread.start();

    while (!producerDone || !consumerDone) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}

From source file:ubic.gemma.loader.genome.goldenpath.GoldenPathBioSequenceLoader.java

/**
 * Load from a database source./*  www . j  a v a2  s.  c  om*/
 * 
 * @param dumper
 */
public void load(final GoldenPathDumper dumper) {
    final BlockingQueue<BioSequence> queue = new ArrayBlockingQueue<BioSequence>(QUEUE_SIZE);

    final SecurityContext context = SecurityContextHolder.getContext();
    assert context != null;
    Thread parseThread = new Thread(new Runnable() {
        @Override
        public void run() {
            dumper.dumpTranscriptBioSequences(limit, queue);
            log.info("Done dumping");
            producerDone = true;
        }
    }, "Parser");

    parseThread.start();

    Thread loadThread = new Thread(new Runnable() {
        @Override
        public void run() {
            SecurityContextHolder.setContext(context);
            log.info("Starting loading");
            load(queue);
        }
    }, "Loader");

    loadThread.start();

    while (!producerDone || !consumerDone) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

From source file:ubic.gemma.loader.protein.StringProteinInteractionLoader.java

/**
 * Thead to handle loading Gene2GeneProteinAssociation into db.
 * /*from w  ww  . j  av a  2s.  c o  m*/
 * @param geneQueue a blocking queue of genes to be loaded into the database loads genes into the database
 */
private void load(final BlockingQueue<Gene2GeneProteinAssociation> gene2GeneProteinAssociationQueue) {
    final SecurityContext context = SecurityContextHolder.getContext();
    assert context != null;

    Thread loadThread = new Thread(new Runnable() {
        @Override
        public void run() {
            SecurityContextHolder.setContext(context);
            doLoad(gene2GeneProteinAssociationQueue);
        }

    }, "Loading");
    loadThread.start();

    while (!converterDone.get() || !loaderDone.get()) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}