Package voxo.server.exceptions

Examples of voxo.server.exceptions.RequestException


    // Check Login
    ArrayList<User> alu = UserManager.searchUserAbsolute(new User(null, username, null, null, null, null, null));

    // Not found / logged
    if (alu.size() == 0) {
      throw new RequestException(Messages.getString("UserLogoutAction.ERR_UserNotFound")); //$NON-NLS-1$
    }

    // Set offline
    User u = alu.get(0);
    u.setOnline(false);
View Full Code Here


  public ContactAddAction(InetAddress ip, ClientRequestPacket o) throws UnknownHostException, IOException, SQLException, RequestException {
    // Get the clients affected
    User u = UserManager.searchUserAbsolute(new User(null, o.getUsername(), null, null, null, null, null)).get(0);
    User cu = UserManager.searchUserAbsolute(new User(null, o.getContactName(), null, null, null, null, null)).get(0);
    if (cu == null) {
      throw new RequestException(Messages.getString("ContactAddAction.ERR_ContactNotFound")); //$NON-NLS-1$
    }
    if (u == null) {
      throw new RequestException(Messages.getString("ContactAddAction.ERR_UserNotFound")); //$NON-NLS-1$
    }

    // Check for existing contact
    Contact c = new Contact(null, u.getUserId(), cu.getUserId(), null);
    ArrayList<Contact> alc = ContactManager.searchContactAbsolute(c);
    if (alc.size() > 0) {
      new SendMessageAction(Messages.getString("ContactAddAction.AlreadySent"), u, EnumPacket.SERVER_Error); //$NON-NLS-1$
      throw new RequestException(Messages.getString("ContactAddAction.ERR_AlreadyContact")); //$NON-NLS-1$
    }

    // Add contact
    ContactManager.addContact(new Contact(null, u.getUserId(), cu.getUserId(), false));
View Full Code Here

  public ContactAcceptAction(InetAddress ip, ClientRequestPacket o) throws UnknownHostException, IOException, SQLException, RequestException {
    // Get the clients affected
    User u = UserManager.searchUserAbsolute(new User(null, o.getUsername(), null, null, ip.getHostAddress(), true, null)).get(0);
    User cu = UserManager.searchUserAbsolute(new User(null, o.getContactName(), null, null, null, null, null)).get(0);
    if (u == null) {
      throw new RequestException(Messages.getString("ContactAcceptAction.ERR_UserNotFound")); //$NON-NLS-1$
    }
    if (cu == null) {
      throw new RequestException(Messages.getString("ContactAcceptAction.ERR_ContactUserNotFound")); //$NON-NLS-1$
    }

    // Get existing contact
    Contact c = new Contact(null, cu.getUserId(), u.getUserId(), null);
    ArrayList<Contact> alc = ContactManager.searchContactAbsolute(c);
    if (alc.size() != 1) {
      throw new RequestException(Messages.getString("ContactAcceptAction.ERR_AlreadyContact")); //$NON-NLS-1$
    }

    // Update contact status
    Contact cAccept = alc.get(0);
    cAccept.setAccepted(true);
View Full Code Here

  public UserRegisterAction(InetAddress ip, RegisterPacket o) throws UnknownHostException, IOException, SQLException, RequestException {
    // Validators
    if (o.getEmail().matches(Messages.getString("UserRegisterAction.CFG_RegexEmail"))) { //$NON-NLS-1$
      // TODO
      new SendMessageAction(Messages.getString("UserRegisterAction.InvalidEmail"), new User(null, null, null, null, ip.getHostAddress(), null, null), EnumPacket.SERVER_Error); //$NON-NLS-1$
      throw new RequestException(Messages.getString("UserRegisterAction.ERR_FailedEmailRegex")); //$NON-NLS-1$
    }
    if (o.getPwd().length() < 6) {
      new SendMessageAction(Messages.getString("UserRegisterAction.InvalidPassword"), new User(null, null, null, null, ip.getHostAddress(), null, null), EnumPacket.SERVER_Error); //$NON-NLS-1$
      throw new RequestException(Messages.getString("UserRegisterAction.ERR_FailedPassword")); //$NON-NLS-1$
    }

    // Check existing
    ArrayList<User> alChecks = UserManager.searchUserOr(new User(null, o.getUsername(), null, o.getEmail(), null, null, null));
    if (alChecks.size() > 0) {
      if (alChecks.get(0).getEmail() == o.getEmail()) {
        new SendMessageAction(Messages.getString("UserRegisterAction.EmailUsed"), new User(null, null, null, null, ip.getHostAddress(), null, null), EnumPacket.SERVER_Error); //$NON-NLS-1$
        throw new RequestException(Messages.getString("UserRegisterAction.ERR_EmailExist")); //$NON-NLS-1$
      } else if (alChecks.get(0).getUsername() == o.getUsername()) {
        new SendMessageAction(Messages.getString("UserRegisterAction.UsernameUsed"), new User(null, null, null, null, ip.getHostAddress(), null, null), EnumPacket.SERVER_Error); //$NON-NLS-1$
        throw new RequestException(Messages.getString("UserRegisterAction.ERR_UsernameExist")); //$NON-NLS-1$
      }
      return;
    }

    // Create user
View Full Code Here

  public ContactRemoveAction(InetAddress ip, ClientRequestPacket o) throws UnknownHostException, IOException, SQLException, RequestException {
    // Get the clients affected and the contact entry
    User u = UserManager.searchUserAbsolute(new User(null, o.getUsername(), null, null, ip.getHostAddress(), true, null)).get(0);
    User cu = UserManager.searchUserAbsolute(new User(null, o.getContactName(), null, null, null, null, null)).get(0);
    if (u == null) {
      throw new RequestException(Messages.getString("ContactRemoveAction.ERR_UserNotFound")); //$NON-NLS-1$
    }
    if (cu == null) {
      throw new RequestException(Messages.getString("ContactRemoveAction.ERR_ContactUserNotFound")); //$NON-NLS-1$
    }
    Contact c = ContactManager.searchContactAbsolute(new Contact(null, cu.getUserId(), u.getUserId(), null)).get(0);
    if (c == null) {
      throw new RequestException(Messages.getString("ContactRemoveAction.ERR_ContactNotFound")); //$NON-NLS-1$
    }

    // Delete contact
    ContactManager.deleteContact(c);
View Full Code Here

public class SendEmailAction {
  public SendEmailAction(InetAddress ip, ChatPacket cp) throws SQLException, RequestException, MessagingException, UnknownHostException, IOException {
    User to = UserManager.searchUserAbsolute(new User(null, cp.getTo(), null, null, null, null, null)).get(0);
    User from = UserManager.searchUserAbsolute(new User(null, cp.getUsername(), null, null, null, null, null)).get(0);
    if (to == null) {
      throw new RequestException();
    }
    if (from == null) {
      throw new RequestException(Messages.getString("ContactAddAction.ERR_UserNotFound")); //$NON-NLS-1$
    }
    MailService.sendMail(from.getEmail(), from.getUsername(), to.getEmail(), to.getUsername(), String.format(Messages.getString("SendEmailAction.MailSubject"), from.getUsername()), String.format(Messages.getString("SendEmailAction.MailBody"), cp.getTxtMsg())); //$NON-NLS-1$ //$NON-NLS-2$
    NetworkService.sendPacket(ip, new Packet(EnumPacket.SERVER_Notice, Messages.getString("SendEmailAction.MailSentResponce"))); //$NON-NLS-1$
  }
View Full Code Here

  public UserLoginAction(InetAddress ip, LoginPacket lp) throws SQLException, UnknownHostException, IOException, RequestException {
    // Check Login
    ArrayList<User> alu = UserManager.searchUserAbsolute(new User(null, lp.getUsername(), lp.getPwd(), null, null, null, null));
    if (alu.size() != 1) {
      NetworkService.sendPacket(ip, new Packet(EnumPacket.SERVER_Error, Messages.getString("UserLoginAction.UsernamePasswordInvalid"))); // Send notice //$NON-NLS-1$
      throw new RequestException(Messages.getString("UserLoginAction.ERR_WrongUsername")); //$NON-NLS-1$
    }

    // Get the user
    User u = alu.get(0);

    // Check if already logged
    if (u.getOnline()) {
      NetworkService.sendPacket(u.getIp(), new Packet(EnumPacket.SERVER_Error, Messages.getString("UserLoginAction.ERR_DualLoginKick"))); //$NON-NLS-1$
      new KickUserAction(u);
      throw new RequestException(Messages.getString("UserLoginAction.ERR_DualLogin"));
    }
   
    // Set online
    u.setOnline(true);
    u.setIp(ip.getHostAddress());
View Full Code Here

TOP

Related Classes of voxo.server.exceptions.RequestException

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.