Package org.hive2hive.core.processes.implementations.notify

Source Code of org.hive2hive.core.processes.implementations.notify.UserProfileTaskNotificationMessage

package org.hive2hive.core.processes.implementations.notify;

import net.tomp2p.peers.PeerAddress;

import org.hive2hive.core.network.messages.direct.BaseDirectMessage;
import org.hive2hive.core.processes.ProcessFactory;
import org.hive2hive.core.processes.framework.abstracts.ProcessComponent;
import org.hive2hive.core.processes.framework.exceptions.InvalidProcessStateException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* A general user profile task notification message which encourages the receiver to check his user profile
* task queue.
*
* @author Seppi
*/
public class UserProfileTaskNotificationMessage extends BaseDirectMessage {

  private static final long serialVersionUID = 1614762764885721467L;

  private final static Logger logger = LoggerFactory.getLogger(UserProfileTaskNotificationMessage.class);

  private final String senderId;

  public UserProfileTaskNotificationMessage(PeerAddress targetAddress, String senderId) {
    super(targetAddress);
    this.senderId = senderId;
  }

  @Override
  public void run() {
    logger.debug("Received a user profile task notification from '{}'.", senderId);
    try {
      ProcessComponent process = ProcessFactory.instance().createUserProfileTaskStep(networkManager);
      process.start();
    } catch (InvalidProcessStateException e) {
      logger.error("Cannot handle user profile task queue. Currently no user is logged in.");
    }
  }
}
TOP

Related Classes of org.hive2hive.core.processes.implementations.notify.UserProfileTaskNotificationMessage

TOP
Copyright © 2018 www.massapi.com. 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.