Package org.cyclop.model

Examples of org.cyclop.model.UserIdentifier$Adapter


    cookieStorage.storeCookieAsJson(CookieStorage.CookieName.cyclop_userid, new UserIdentifierCookie(id));
  }

  @Override
  public UserIdentifier readIdentifier() {
    UserIdentifier id = null;
    Optional<UserIdentifierCookie> cookie = cookieStorage.readCookieAsJson(CookieStorage.CookieName.cyclop_userid,
        UserIdentifierCookie.class);
    if (!cookie.isPresent()) {
      id = new UserIdentifier();
      storeIdentifier(id);
      LOG.info("Generated new User Identifier: " + id.id);
    } else {
      id = cookie.get().getId();
    }
View Full Code Here


  protected abstract Class<H> getClazz();

  protected abstract H createEmpty();

  protected UserIdentifier getUser() {
    final UserIdentifier fromCookie = um.readIdentifier();
    if (identifier == null) {
      LOG.debug("Using identifier from cookie: {}", fromCookie);
      identifier = fromCookie;
    } else {

      // make sure that there is only one user identifier pro http session
      // if it's not the case overwrite new one with existing one
      if (!fromCookie.equals(identifier)) {
        LOG.debug("Replacing {} with {}", fromCookie, identifier);
        um.storeIdentifier(identifier);
      }
    }
    return identifier;
View Full Code Here

  @Override
  public void store(@NotNull H newHistory) {
    LOG.debug("String history");
    history.set(newHistory);
    final UserIdentifier user = getUser();

    // this synchronization ensures that history will be not added to write
    // queue while it's being read from
    // disk in #readHistory()
    synchronized (asyncFileStore) {
View Full Code Here

    LOG.debug("Accessing history");
    if (history.get() == null) {
      synchronized (asyncFileStore) {
        LOG.debug("Reading history");
        if (history.get() == null) {
          final UserIdentifier user = getUser();

          // history can be in write queue when user closes http
          // session and opens new few seconds later.
          // in this case async queue might be not flushed to disk yet
          final Optional<H> readOpt = asyncFileStore.getFromWriteQueue(user);
View Full Code Here

  @Scheduled(initialDelay = FLUSH_MILIS, fixedDelay = FLUSH_MILIS)
  @PreDestroy
  public synchronized void flush() {
    LOG.debug("Flushing history");
    while (true) {
      UserIdentifier identifier;
      H history;

      // synchronize #historyMap only for short time to not block
      // store(...) function by file operation
      synchronized (diskQueue) {
View Full Code Here

    assertTrue("History folder not writable:" + histFolder, histFolder.canWrite());
  }

  @Test(expected = BeanValidationException.class)
  public void testRead_Validation() {
    storage.read(new UserIdentifier(), null);
  }
View Full Code Here

    storage.read(new UserIdentifier(), null);
  }

  @Test(expected = BeanValidationException.class)
  public void testRead_Validation_IncorrectUserIdentifier() {
    storage.read(new UserIdentifier(null), String.class);
  }
View Full Code Here

    storage.read(new UserIdentifier(null), String.class);
  }

  @Test(expected = BeanValidationException.class)
  public void testStore_Validation() {
    storage.store(new UserIdentifier(), null);
  }
View Full Code Here

    storage.store(new UserIdentifier(), null);
  }

  @Test(expected = BeanValidationException.class)
  public void testStore_Validation_IncorrectUserIdentifier() {
    storage.store(new UserIdentifier(null), String.class);
  }
View Full Code Here

    assertFalse(storage.checkSupported());
  }

  @Test
  public void testRead_FileNotFound() {
    assertFalse(storage.read(new UserIdentifier(UUID.randomUUID()), QueryHistory.class).isPresent());
  }
View Full Code Here

TOP

Related Classes of org.cyclop.model.UserIdentifier$Adapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.