Package de.iritgo.aktera.model

Examples of de.iritgo.aktera.model.ModelRequest


    }
  }

  protected void socketServiceLoop()
  {
    ModelRequest req = null;
    ObjectInputStream reader = null;

    try
    {
      while (! serverSocket.isClosed())
      {
        try
        {
          if (logger.isDebugEnabled())
          {
            logger.debug("Request " + getName() + " starts");
          }

          MultiThreadedProcessor processor = new MultiThreadedProcessor(serverSocket.accept());

          logger.debug("Client connection established.");
          processor.start();

          if (logger.isDebugEnabled())
          {
            logger.debug("Request " + getName() + " serviced");
          }
        }
        catch (Exception e)
        {
          logger.error("Error while processing request: " + e);
        }
        finally
        {
          if (reader != null)
          {
            try
            {
              reader.close();
            }
            catch (Exception ignore)
            {
            }
          }
        }
      }
    }
    catch (Exception e)
    {
      logger.error("Exception while servicing request:", e);
      throw new RuntimeException(e);
    }
    finally
    {
      if (req != null)
      {
        if (logger.isDebugEnabled())
        {
          logger.debug("Releasing request " + req.toString());
        }

        myContainer.release(req);
      }
    }
View Full Code Here


    if (getContainer() == null)
    {
      throw new ModelException("Initialization failed - container is null");
    }

    ModelRequest req = null;

    try
    {
      Object o = getContainer().getService(ModelRequest.ROLE);

      if (o == null)
      {
        getLogger().error("Service returned was null");
      }

      req = (ModelRequest) o;
    }
    catch (Exception se)
    {
      getLogger().error("Service Exception:", se);
      throw new ModelException("Service Exception getting request", se);
    }

    try
    {
      req.copyFrom(request);
    }
    catch (Exception ee)
    {
      getLogger().error("Error copying ModelRequestMessage to ModelRequest", ee);
    }

    //Set the context to that provided in the original request
    if (req instanceof KeelContextualizable)
    {
      try
      {
        ((KeelContextualizable) req).setKeelContext(getContext(req));
      }
      catch (ContextException e)
      {
        throw new ModelException("Unable to set keel context on ModelRequest", e);
      }
    }

    getLogger().debug("Executing model " + req.getModel());

    /**
     * We don't fail on a ModelException, we just stuff it into the
     * model response and carry on, so that the client gets the
     * exception
     */
    ModelResponse res = null;
    ModelResponseMessage resMessage = new ModelResponseMessage();

    try
    {
      res = req.execute();
    }
    catch (ModelException me)
    {
      resMessage.addError("model", me);

View Full Code Here

    if (getContainer() == null)
    {
      throw new ModelException("Initialization failed - container is null");
    }

    ModelRequest req = null;

    try
    {
      Object o = getContainer().getService(ModelRequest.ROLE);

      if (o == null)
      {
        getLogger().error("Service returned was null");
      }

      req = (ModelRequest) o;
    }
    catch (Exception se)
    {
      getLogger().error("Service Exception:", se);
      throw new ModelException("Service Exception getting request", se);
    }

    try
    {
      req.copyFrom(request);
    }
    catch (Exception ee)
    {
      getLogger().error("Error copying ModelRequestMessage to ModelRequest", ee);
    }

    // Set the context to that provided in the original request
    if (req instanceof KeelContextualizable)
    {
      try
      {
        ((KeelContextualizable) req).setKeelContext(getContext(req));
      }
      catch (ContextException e)
      {
        throw new ModelException("Unable to set keel context on ModelRequest", e);
      }
    }

    getLogger().debug("Executing model " + req.getModel());

    /**
     * We don't fail on a ModelException, we just stuff it into the
     * model response and carry on, so that the client gets the
     * exception
     */
    ModelResponse res = null;
    ModelResponseMessage resMessage = new ModelResponseMessage();

    try
    {
      res = req.execute();
    }
    catch (ModelException me)
    {
      resMessage.addError("model", me);

View Full Code Here

   * @param keelUniqueId The id from the keel object.
   * @param userUniqueId The user unique id.
   */
  public void deleteKeelObject(String model, String keelObjectId, long userUniqueId)
  {
    ModelRequest req = null;

    try
    {
      req = ModelTools.createModelRequest();

      Model deleteModel = (Model) req.getService(Model.ROLE, model, (Context) keelIritgoAuthMap.get(new Long(
              userUniqueId)));

      ((KeelContextualizable) req).setKeelContext((Context) keelIritgoAuthMap.get(new Long(userUniqueId)));

      req.setParameter("id", keelObjectId);

      deleteModel.execute(req);
    }
    catch (Exception x)
    {
View Full Code Here

   * @return
   */
  @SuppressWarnings("serial")
  public KeelResponse executeModel(Properties properties, long userUniqueId)
  {
    ModelRequest req = null;

    try
    {
      Model model = null;

      req = ModelTools.createModelRequest();

      Context context = (Context) keelIritgoAuthMap.get(new Long(userUniqueId));

      if (context != null)
      {
        model = (Model) req.getService(Model.ROLE, properties.getProperty("model"), context);
      }
      else
      {
        UserEnvironment userEnvironment = new DefaultUserEnvironment()
        {
          private LinkedList<String> fakeList;

          public List<String> getGroups()
          {
            if (fakeList == null)
            {
              fakeList = new LinkedList<String>();
              fakeList.add(new String("root"));
            }

            return fakeList;
          }
        };

        context = new DefaultContext();
        ((DefaultContext) context).put(UserEnvironment.CONTEXT_KEY, userEnvironment);

        model = (Model) req.getService(Model.ROLE, properties.getProperty("model"), context);
      }

      ((KeelContextualizable) req).setKeelContext(context);

      String attributeName = null;

      for (Iterator i = properties.keySet().iterator(); i.hasNext();)
      {
        attributeName = (String) i.next();

        req.setParameter(attributeName, properties.get(attributeName));
      }

      KeelResponse res = model.execute(req);

      return res;
View Full Code Here

   */
  private KeelResponse getKeelObject(String model, String keelObjectId, long userUniqueId)
  {
    KeelResponse res = null;

    ModelRequest req = null;

    try
    {
      req = ModelTools.createModelRequest();

      Model editModel = (Model) req.getService(Model.ROLE, model, (Context) keelIritgoAuthMap.get(new Long(
              userUniqueId)));

      ((KeelContextualizable) req).setKeelContext((Context) keelIritgoAuthMap.get(new Long(userUniqueId)));

      req.setParameter("id", keelObjectId);

      res = editModel.execute(req);
    }
    catch (Exception x)
    {
View Full Code Here

   */
  private KeelResponse getKeelResultList(String model, String listName, long userUniqueId, String searchCondition,
          String listSearchCategory)
  {
    KeelResponse res = null;
    ModelRequest req = null;

    try
    {
      req = ModelTools.createModelRequest();

      Model listingModel = (Model) req.getService(Model.ROLE, model, (Context) keelIritgoAuthMap.get(new Long(
              userUniqueId)));

      ((KeelContextualizable) req).setKeelContext((Context) keelIritgoAuthMap.get(new Long(userUniqueId)));

      req.setParameter("listId", "list");
      req.setParameter("recordsPerPage", new Integer(100));
      req.setParameter("listSearch", searchCondition);
      req.setParameter("aktario", "true");

      if (! listSearchCategory.equals(""))
      {
        req.setParameter("listSearchCategory", listSearchCategory);
        req.setParameter(listName + "SearchCategory", listSearchCategory);
      }

      res = listingModel.execute(req);
    }
    catch (Exception x)
View Full Code Here

   * @param Properties properties
   * @param long userUniqueId
   */
  public void getPersistentAttributes(Properties properties, long userUniqueId)
  {
    ModelRequest req = null;

    try
    {
      Model model = null;

      req = ModelTools.createModelRequest();

      Context context = (Context) keelIritgoAuthMap.get(new Long(userUniqueId));

      PersistentFactory persistentManager = null;

      if (context != null)
      {
        persistentManager = (PersistentFactory) req.getService(PersistentFactory.ROLE, "", context);
      }
      else
      {
        UserEnvironment userEnvironment = new DefaultUserEnvironment()
        {
          private LinkedList<String> fakeList;

          public List<String> getGroups()
          {
            if (fakeList == null)
            {
              fakeList = new LinkedList<String>();
              fakeList.add(new String("root"));
            }

            return fakeList;
          }
        };

        context = new DefaultContext();
        ((DefaultContext) context).put(UserEnvironment.CONTEXT_KEY, userEnvironment);

        persistentManager = (PersistentFactory) req.getService(PersistentFactory.ROLE, "", context);
      }

      ((KeelContextualizable) req).setKeelContext(context);

      Persistent persistent = persistentManager.create(properties.getProperty("persistent"));
View Full Code Here

      {
        props.put(key.substring(3), ((Map.Entry) entry).getValue());
      }
    }

    ModelRequest newReq = (ModelRequest) req.getService(ModelRequest.ROLE);

    return ModelTools.callModel(newReq, req.getParameterAsString("_cmodel"), props);
  }
View Full Code Here

        context.setSaveId(id);

        CommandInfo cmdInfo = (CommandInfo) cmdOk.clone();
        Command cmd = cmdInfo.createCommand(req, res, context);

        ModelRequest newReq = (ModelRequest) req.getService(ModelRequest.ROLE);
        ModelResponse cmdRes = cmd.execute(newReq, res);

        if (res.get("IRITGO_formMessages") != null)
        {
          cmdRes.add(res.get("IRITGO_formMessages"));
View Full Code Here

TOP

Related Classes of de.iritgo.aktera.model.ModelRequest

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.