Search in sources :

Example 1 with Lexicon

use of edu.stanford.muse.index.Lexicon in project epadd by ePADD.

the class SimpleSessions method prepareAndLoadArchive.

public static Archive prepareAndLoadArchive(MuseEmailFetcher m, HttpServletRequest request) throws IOException {
    // here's where we create a fresh archive
    String userKey = "user";
    /*if (ModeConfig.isServerMode())
		{
			// use existing key, or if not available, ask the fetcher which has the login email addresses for a key
			userKey = (String) session.getAttribute("userKey");
			if (Util.nullOrEmpty(userKey))
				userKey = m.getEffectiveUserKey();
			Util.ASSERT(!Util.nullOrEmpty(userKey)); // disaster if we got here without a valid user key
		}*/
    int i = new Random().nextInt();
    String randomPrefix = String.format("%08x", i);
    String archiveDir = ModeConfig.isProcessingMode() ? Config.REPO_DIR_PROCESSING + File.separator + randomPrefix : SimpleSessions.CACHE_BASE_DIR + File.separator + userKey;
    // String archiveDir = Sessions.CACHE_BASE_DIR + File.separator + userKey;
    Archive archive = SimpleSessions.readArchiveIfPresent(archiveDir);
    if (archive != null) {
        JSPHelper.log.info("Good, existing archive found");
    } else {
        JSPHelper.log.info("Creating a new archive in " + archiveDir);
        archive = JSPHelper.preparedArchive(request, archiveDir, new ArrayList<>());
        // by this time the archive is created
        // add this to global maps archiveID->archive, archive->archiveID
        addToGlobalArchiveMap(archiveDir, archive);
    }
    Lexicon lex = archive.getLexicon("general");
    /*	if (lex != null)
			session.setAttribute("lexicon", lex); // set up default general lexicon, so something is in the session as default lexicon (so facets can show it)
	*/
    return archive;
}
Also used : Archive(edu.stanford.muse.index.Archive) Lexicon(edu.stanford.muse.index.Lexicon)

Aggregations

Archive (edu.stanford.muse.index.Archive)1 Lexicon (edu.stanford.muse.index.Lexicon)1