Package org.objectweb.joram.shared.excepts

Examples of org.objectweb.joram.shared.excepts.RequestException


        dest = new Queue();
      } else if (DestinationConstants.isTopic(req.getType())) {
        // Create a local topic.
        dest = new Topic();
      } else {
        throw new RequestException("Could not create destination, unknown type:" + req.getType());
      }
      dest.setName(req.getName());
      dest.setAdminId(getId());
      dest.setFreeWriting(true); // Setting free WRITE right on the destination
      if (! DestinationConstants.isTemporary(req.getType()))
        dest.setFreeReading(true); // Setting free READ right on the destination
      destId = dest.getId();
      try {
        dest.deploy();
      } catch (IOException exc) {
        throw new RequestException("Could not create destination:" + exc.getMessage());
      }
      // Registers the newly created destination
      AdminTopic.registerDest(destId, (req.getName() == null) ? destId.toString() : req.getName(),
          req.getType());
View Full Code Here


  private void doReact(ConsumerSubRequest req) throws StateException, RequestException {
    AgentId topicId = AgentId.fromString(req.getTarget());
    String subName = req.getSubName();
   
    if (topicId == null)
      throw new RequestException("Cannot subscribe to an undefined topic (null).");
   
    if (subName == null)
      throw new RequestException("Unauthorized null subscription name.");
   
    boolean newTopic = ! topicsTable.containsKey(topicId);
    boolean newSub = ! subsTable.containsKey(subName);

    TopicSubscription tSub;
View Full Code Here

    // Retrieving an existing destination:
    if (destName != null && ! destName.equals("") && destinationsTable.containsKey(destName)) {
      destDesc = (DestinationDesc) destinationsTable.get(destName);
      if (! DestinationConstants.compatible(destDesc.getType(), type)) {
        throw new RequestException("Destination type not compliant");
      }
      strbuf.append("Request [").append(requestClassName)
      .append("], processed by AdminTopic on server [").append(serverId)
      .append("], successful [true]: destination [")
      .append(destName).append("] has been retrieved");
    } else {
      // Instantiating the destination class.
      Destination dest = null;
      try {
        dest = (Destination) Class.forName(className).newInstance();
        dest.setName(destName);
        dest.setAdminId(adminId);
        dest.setProperties(properties, true);
      } catch (Exception exc) {
        logger.log(BasicLevel.ERROR,
                   "Could not instantiate Destination class [" + className + "]: ", exc);
        if (exc instanceof ClassCastException)
          throw new RequestException("Class [" + className + "] is not a Destination class.");

        throw new RequestException("Could not instantiate Destination class [" + className + "]: " + exc);
      }
     
      byte destType = dest.getType();
      if (! DestinationConstants.compatible(destType, type)) {
        throw new RequestException("Requested destination type is not compliant with destination classname");
      }

      if (destName == null || destName.equals(""))
        destName = dest.getAgentId();

      destDesc = new DestinationDesc(dest.getId(), destName, destType);
      try {
        dest.deploy();
        destinationsTable.put(destName, destDesc);

        strbuf.append("Request [").append(requestClassName)
        .append("], processed by AdminTopic on server [").append(serverId)
        .append("], successful [true]: ").append(className).append(" [")
        .append(dest.getAgentId()).append("] has been created and deployed");

      } catch (Exception exc) {
        if (logger.isLoggable(BasicLevel.ERROR))
          logger.log(BasicLevel.ERROR, "xxx", exc);
        throw new RequestException("Error while deploying Destination [" + className + "]: " + exc);
      }
    }
    return destDesc;
  }
View Full Code Here

        Identity userIdentity = (Identity) usersTable.get(name);
        if (logger.isLoggable(BasicLevel.INFO))
          logger.log(BasicLevel.INFO, "User [" + name + "] already exists : " + userIdentity);
        try {
          if (! userIdentity.check(identity)) {
            throw new RequestException("User [" + name + "] already exists"
                                       + " but with a different password.");
          }
        } catch (Exception e) {
          throw new RequestException("User [" + name + "] already exists :: Exception :" + e.getMessage());
        }
        info = strbuf.append("Request [").append(request.getClass().getName())
        .append("], processed by AdminTopic on server [").append(serverId)
        .append("], successful [true]: proxy [").append(proxId.toString())
        .append("] of user [").append(name)
        .append("] has been retrieved").toString();
        strbuf.setLength(0);
      } else {
//        try {
//          if (! identity.validate()) {
//            throw new RequestException("User [" + name + "] security validate failed.");
//          }
//        } catch (Exception e) {
//          throw new RequestException(e.getMessage());
//        }

        UserAgent proxy = new UserAgent();
        proxy.setName(name);
        proxId = proxy.getId();
       
        // set interceptors.
        proxy.setInterceptors(request.getProperties());
       
        try {
          // deploy UserAgent
          proxy.deploy();
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG, "doProcess CreateUserRequest:: store (in usersTable) this identity = " + identity);
          usersTable.put(name, identity);
          proxiesTable.put(name, proxy.getId());

          info = strbuf.append("Request [").append(request.getClass().getName())
          .append("], processed by AdminTopic on server [").append(serverId)
          .append("], successful [true]: proxy [")
          .append(proxId.toString()).append("] for user [").append(name)
          .append("] has been created and deployed").toString();
          strbuf.setLength(0);
        }
        catch (Exception exc) {
          if (logger.isLoggable(BasicLevel.ERROR))
            logger.log(BasicLevel.ERROR, "EXCEPTION:: createUser [" + name + "]", exc);
          throw new RequestException("User proxy not deployed: " + exc);
        }
      }

      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, info);
View Full Code Here

      // If the user belong to this server, process the request.
      String info;

      // If the user does not exist: throwing an exception:
      if (! usersTable.containsKey(name))
        throw new RequestException("User [" + name + "] does not exist");

      Identity newIdentity = request.getNewIdentity();
      // If the new name is already taken by an other user than the modified
      // one:
      if (! newIdentity.getUserName().equals(name)
          && (usersTable.containsKey(newIdentity.getUserName())))
        throw new RequestException("Name [" + newIdentity.getUserName() + "] already used");

      if (usersTable.containsKey(name)) {
        usersTable.remove(name);
        proxiesTable.remove(name);
        if (logger.isLoggable(BasicLevel.DEBUG))
View Full Code Here

      if (passwd != null)
        identity.setIdentity(user, passwd);
      else
        identity.setUserName(user);
    } catch (Exception e) {
      throw new RequestException(e.getMessage());
    }
    CreateUserRequest request = new CreateUserRequest(identity, serverId, null);
    FwdAdminRequestNot createNot = new FwdAdminRequestNot(request, null, null);
    Channel.sendTo(getId(), createNot);
  }
View Full Code Here

    DestinationDesc desc = null;
   
    if (name != null && name.length() > 0) {
      desc = (DestinationDesc) ref.destinationsTable.get(name);
      if ((desc != null) && (! DestinationConstants.compatible(desc.getType(), type))) {
        throw new RequestException("Destination type not compliant");
      }
    }
    return desc;
  }
View Full Code Here

TOP

Related Classes of org.objectweb.joram.shared.excepts.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.