Examples of ModelResponse


Examples of de.iritgo.aktera.model.ModelResponse

   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    SystemFirewall.disable();

    ModelResponse res = req.createResponse();
    Command cmd = res.createCommand("aktera.database.create");
    cmd.setName("create");
    cmd.setLabel("$createDatabase");
    res.add(cmd);

    return res;
  }
View Full Code Here

Examples of de.iritgo.aktera.model.ModelResponse

   * @param req The model request.
   * @throws ModelException In case of a business failure.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();

    Output outUserId = res.createOutput("userId");

    outUserId.setContent(new Integer(1));
    res.add(outUserId);

    return res;
  }
View Full Code Here

Examples of de.iritgo.aktera.model.ModelResponse

  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    log.info("*** Unblock firewall for database update...");
    SystemFirewall.disable();

    ModelResponse res = req.createResponse();

    Command cmd = res.createCommand("aktera.database.update");

    cmd.setName("update");
    cmd.setLabel("$updateDatabase");
    res.add(cmd);

    return res;
  }
View Full Code Here

Examples of de.iritgo.aktera.model.ModelResponse

   * @param request The model request.
   * @return The model response.
   */
  public ModelResponse execute(ModelRequest request) throws ModelException
  {
    ModelResponse response = request.createResponse();

    String downloadDir = getConfiguration().getChild("directory").getValue(null);

    if (downloadDir == null)
    {
      log.error("No download directory specified");
      throw new ModelException("No download directory specified");
    }

    String urlBase = getConfiguration().getChild("url").getValue(null);

    if (urlBase == null)
    {
      log.error("No URL base specified");
      throw new ModelException("No URL base specified");
    }

    Output outList = response.createOutput("list");

    response.add(outList);

    List<File> files = new LinkedList(FileUtils.listFiles(FileTools.newAkteraFile(downloadDir),
            TrueFileFilter.INSTANCE, null));

    Collections.sort(files, new Comparator<File>()
    {
      public int compare(File o1, File o2)
      {
        return o1.getName().compareToIgnoreCase(o2.getName());
      }
    });

    for (File file : files)
    {
      Output outFile = response.createOutput("file" + file.hashCode());

      outFile.setContent(file.getName());
      outFile.setAttribute("extension", FilenameUtils.getExtension(file.getName()));
      outFile.setAttribute("url", urlBase + "/" + file.getName());
      outList.add(outFile);
    }

    response.setAttribute("forward", "aktera.tools.download-list");

    return response;
  }
View Full Code Here

Examples of de.iritgo.aktera.model.ModelResponse

   * @param req The model request.
   * @throws ModelException In case of a business failure.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();

    try
    {
      UpdateHelper.update(req, res, null);
    }
    catch (ServiceException x)
    {
      throw new ModelException(x);
    }

    Command cmd = res.createCommand("aktera.tools.goto-start-model");

    cmd.setName("cmd");
    res.add(cmd);

    return res;
  }
View Full Code Here

Examples of de.iritgo.aktera.model.ModelResponse

  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    PersistentFactory persistentFactory = (PersistentFactory) req.getService(PersistentFactory.ROLE, req
            .getDomain());

    ModelResponse res = req.createResponse();

    DataSourceComponent dataSourceComponent = (DataSourceComponent) req.getService(DataSourceComponent.ROLE,
            "keel-dbpool");

    List<Configuration> moduleConfigs = de.iritgo.aktera.base.module.ModuleInfo
            .moduleConfigsSortedByDependency(req);

    try
    {
      Connection connection = null;

      try
      {
        connection = dataSourceComponent.getConnection();

        for (Configuration moduleConfig : moduleConfigs)
        {
          String moduleId = moduleConfig.getAttribute("id", "unkown");
          String createHandlerClassName = moduleConfig.getChild("create").getAttribute("class", null);

          if (createHandlerClassName != null)
          {
            try
            {
              System.out.println("CreateDatabase: Creating tables of module '" + moduleId
                      + "' with handler '" + createHandlerClassName + "'");

              Class klass = Class.forName(createHandlerClassName);

              if (klass != null)
              {
                CreateHandler createHandler = (CreateHandler) klass.newInstance();
                createHandler.setConnection(connection);
                createHandler.createTables(req, persistentFactory, connection, log);
              }
              else
              {
                log
                        .error("CreateDatabase: Unable to find create handler for module '"
                                + moduleId + "'");
              }
            }
            catch (ClassNotFoundException x)
            {
              log.error("CreateDatabase: Unable call create handler for module '" + moduleId + "': " + x);
            }
            catch (Exception x)
            {
              res.addOutput("databaseError", x.getMessage());
              res.addOutput("databaseErrorStackTrace", StringTools.stackTraceToString(x).replaceAll("\n",
                      "<br>"));

              return res;
            }
          }
        }
      }
      catch (SQLException x)
      {
        log.error("Unable to create database connection", x);
      }
      finally
      {
        try
        {
          connection.close();
        }
        catch (SQLException x)
        {
        }
      }

      connection = null;

      try
      {
        connection = dataSourceComponent.getConnection();

        for (Configuration moduleConfig : moduleConfigs)
        {
          String moduleId = moduleConfig.getAttribute("id", "unkown");
          String createHandlerClassName = moduleConfig.getChild("create").getAttribute("class", null);

          if (createHandlerClassName != null)
          {
            try
            {
              System.out.println("CreateDatabase: Creating data of module '" + moduleId
                      + "' with handler '" + createHandlerClassName + "'");

              Class klass = Class.forName(createHandlerClassName);

              if (klass != null)
              {
                CreateHandler createHandler = (CreateHandler) klass.newInstance();
                createHandler.setConnection(connection);
                createHandler.createData(persistentFactory, connection, log, req);
              }
              else
              {
                log
                        .error("CreateDatabase: Unable to find create handler for module '"
                                + moduleId + "'");
              }
            }
            catch (ClassNotFoundException x)
            {
              log.error("CreateDatabase: Unable call create handler for module '" + moduleId + "': " + x);
            }
            catch (Exception x)
            {
              res.addOutput("databaseError", x.getMessage());
              res.addOutput("databaseErrorStackTrace", StringTools.stackTraceToString(x).replaceAll("\n",
                      "<br>"));

              return res;
            }
          }
        }
      }
      catch (SQLException x)
      {
        log.error("Unable to create database connection", x);
      }
      finally
      {
        try
        {
          connection.close();
        }
        catch (SQLException x)
        {
        }
      }

      try
      {
        for (Configuration moduleConfig : moduleConfigs)
        {
          Persistent version = persistentFactory.create("aktera.Version");

          version.setField("type", "M");
          version.setField("name", moduleConfig.getAttribute("id", "unkown"));
          version.setField("version", moduleConfig.getChild("version").getValue("0.0.0"));
          version.add();
        }
      }
      catch (Exception x)
      {
        System.out.println(x.toString());
      }

      try
      {
        Model appInfo = (Model) req.getService(Model.ROLE, "aktera.app-info");

        Configuration[] appConfigs = appInfo.getConfiguration().getChildren("app");

        for (int i = 0; i < appConfigs.length; ++i)
        {
          Configuration appConfig = appConfigs[i];

          Persistent version = persistentFactory.create("aktera.Version");

          version.setField("type", "A");
          version.setField("name", appConfig.getAttribute("id", "unkown"));
          version.setField("version", appConfig.getChild("version").getValue("0.0.0"));
          version.add();
        }
      }
      catch (Exception x)
      {
        System.out.println(x.toString());
      }

      try
      {
        Persistent config = persistentFactory.create("aktera.SystemConfig");

        config.setField("category", "system");
        config.setField("name", "databaseCreated");
        config.setField("type", "B");
        config.setField("value", "true");

        if (! config.find())
        {
          config.add();
        }
      }
      catch (Exception x)
      {
        System.out.println(x.toString());
      }
    }
    catch (ModelException x)
    {
      res.addOutput("databaseError", x.getMessage());
      res.addOutput("databaseErrorStackTrace", x.getStackTraceAsString().replaceAll("\n", "<br>"));

      return res;
    }

    return res;
View Full Code Here

Examples of de.iritgo.aktera.model.ModelResponse

   * @param request The model request.
   * @return The model response.
   */
  public ModelResponse execute(ModelRequest request) throws ModelException
  {
    ModelResponse response = request.createResponse();

    response.setAttribute("forward", "aktera.redirect");

    String scheme = request.getScheme();
    String serverName = request.getServerName();
    int port = request.getServerPort();
    String baseUrl = scheme + "://" + serverName + (port != ("https".equals(scheme) ? 443 : 80) ? ":" + port : "");
    String contextPath = request.getContextPath();

    String url = configuration.getChild("url").getValue("#");

    url = url.replaceAll("\\#\\{scheme\\}", scheme);
    url = url.replaceAll("\\#\\{server\\}", serverName);
    url = url.replaceAll("\\#\\{port\\}", String.valueOf(port));
    url = url.replaceAll("\\#\\{context\\}", contextPath);
    url = url.replaceAll("\\#\\{baseUrl\\}", baseUrl);
    response.addOutput("url", url);

    return response;
  }
View Full Code Here

Examples of de.iritgo.aktera.model.ModelResponse

   * @param req The model request.
   * @return The model response.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();

    String command = req.getParameterAsString("command");

    if ("update".equals(command))
    {
View Full Code Here

Examples of de.iritgo.aktera.model.ModelResponse

   * @param req The model request.
   * @return The model response.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();

    if (req.getParameter("license") != null)
    {
      try
      {
        String license = req.getParameterAsString("license").replaceAll("\r", "");

        if (! license.endsWith("\n"))
        {
          license += "\n";
        }

        File file = new File(System.getProperty("iritgo.license.path"));
        PrintWriter fileOut = new PrintWriter(file);

        fileOut.print(license);
        fileOut.close();
      }
      catch (Exception x)
      {
        System.out.println("[StoreLicense] " + x);
      }
    }
    else if (req.getParameter("fileUpload1") != null)
    {
      try
      {
        BinaryWrapper data = (BinaryWrapper) req.getParameter("fileUpload1");

        if (data != null)
        {
          File file = new File(System.getProperty("iritgo.license.path"));

          data.write(file);
        }
      }
      catch (Exception x)
      {
        System.out.println("[StoreLicense] " + x);
      }
    }

    Command cmd = res.createCommand("aktera.tools.goto-start-model");

    cmd.setName("cmdLogin");
    res.add(cmd);

    return res;
  }
View Full Code Here

Examples of de.iritgo.aktera.model.ModelResponse

   * @param req The model request.
   * @return The model response.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();

    Input license = res.createInput("license");

    res.add(license);

    Input fileUpload1 = res.createInput("fileUpload1");

    res.add(fileUpload1);

    Command cmd = res.createCommand("aktera.session.store-license");

    cmd.setName("cmdStore");
    res.add(cmd);

    return res;
  }
View Full Code Here
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.