Package de.iritgo.aktera.model

Examples of de.iritgo.aktera.model.ModelException


      sb.append(request.getContextPath());
      sb.append("/");
    }
    catch (Exception x)
    {
      throw new ModelException(x);
    }
    finally
    {
      if (localRequest)
      {
View Full Code Here


        versionMeta.getDatabaseType().createTable(versionMeta, versionMeta.getDataSource());
      }
      catch (PersistenceException xx)
      {
        throw new ModelException(xx);
      }
    }
  }
View Full Code Here

      return runSequence(config, req, mergeDefaultFromSequenceDefinition);
    }
    catch (ConfigurationException ce)
    {
      throw new ModelException("Configuration exception in sequence", ce);
    }
  }
View Full Code Here

      {
        seq = new Integer(seqString).intValue();
      }
      catch (NumberFormatException ne)
      {
        throw new ModelException("Invalid sequence '" + seqString + "'", ne);
      }
    }

    ModelResponse currentResponse = null;
    SequenceContext seqContext = null;

    try
    {
      seqContext = SequenceContext.getSequenceContext(req);

      if (seqContext != null)
      {
        //                 log.debug("Found existing sequence context. Seq= " + (seq));
        String oldSeqName = seqContext.getSequenceName();

        /**
         * Added by ACR. Up until now, problems occured when seq steps from one sequence would
         * bleed into the next sequence, jumping the user up steps.
         * I have changed the system to now assume that when you jump from one sequence to another
         * you want to go to the first step of the next sequence.
         *
         */
        if (! seqName.equals(oldSeqName))
        {
          //                     if (log.isDebugEnabled()) {
          //                       log.debug(
          //                         "Sequence is transitioning, from sequence "
          //                             + oldSeqName
          //                             + " to sequence "
          //                             + seqName
          //                             + ". Clearing sequence variables....");
          //                     }
          //Don't change the seq parameter, because we already read it in above, and we have already set it 1 if
          //there was no sequence param.
          clearSequence(req);
          currentResponse = req.createResponse();
        }
        else
        {
          if (seq != 1)
          {
            //we want to "recycle" the response to keep it going, since we are still in the same sequence....
            currentResponse = seqContext.getCurrentResponse();
          }
          else
          {
            currentResponse = req.createResponse();
          }
        } //end-if-else
      }
      else
      { //seqContext is null, so create a new one
        createNewSeqContext = true;
      } //end-if-else
    }
    catch (ModelException e)
    {
      //Error occured. Start a fresh response....
      currentResponse = req.createResponse();
      createNewSeqContext = true;
      log.error(e.toString());
    }

    clearSequence(req);
    createNewSeqContext = true;
    //Set flag to create a new sequence context.
    params.putAll(req.getParameters());

    Configuration[] children = myConf.getChildren();

    if (seq > children.length)
    {
      log.warn("Requested seq " + seq + " which is more than available steps " + children.length);
      clearSequence(req);

      if (currentResponse != null)
      {
        return currentResponse;
      }
      else
      {
        throw new ModelException("Response for end of sequence was null");
      }
    }

    //Added by Phil Brown to create and save a new Sequence Context if we don't have
    //This is desired so that our models have the sequenceContext available in case they
View Full Code Here

      return c.execute(req, res, true, true);
    }
    catch (ConfigurationException ce)
    {
      throw new ModelException(ce);
    }
  }
View Full Code Here

        count = list.size();
      }
      catch (NoSuchMethodException x)
      {
        throw new ModelException(x);
      }
      catch (IllegalAccessException x)
      {
        throw new ModelException(x);
      }
      catch (InvocationTargetException x)
      {
        throw new ModelException(x.getTargetException());
      }
    }
    else if (query.getCountName() != null)
    {
      count = (int) standardDao.countByNamedQuery(query.getCountName(), queryParams);
    }
    else if (query.getName() != null)
    {
      count = (int) standardDao.countByNamedFindQuery(query.getName(), queryParams);
    }
    else
    {
      if (query.getCountQuery() != null)
      {
        count = (int) standardDao.countByQuery(query.getCountQuery(), queryParams);
      }
      else
      {
        count = (int) standardDao.countByFindQuery(query.getQuery(), queryParams);
      }
    }

    int page = Math.max(listing.getPage(), 1);
    int maxPage = (Math.max(0, count - 1) / context.getResultsPerPage()) + 1;

    page = Math.min(page, maxPage);

    context.setPage(page);
    context.setFirstResult((page - 1) * context.getResultsPerPage());

    Output outList = createHeaderElements(request, response, listing, context);

    outList.setAttribute("pageCount", new Integer(maxPage));
    outList.setAttribute("page", String.valueOf(page));

    int firstResult = (page - 1) * context.getResultsPerPage();
    int maxResults = context.getResultsPerPage();
    java.util.List res = null;

    if (query.getDaoName() != null)
    {
      try
      {
        res = (java.util.List) MethodUtils.invokeExactMethod(SpringTools.getBean(query.getDaoName()), query
                .getDaoMethodName(), queryParams);
      }
      catch (NoSuchMethodException x)
      {
        throw new ModelException(x);
      }
      catch (IllegalAccessException x)
      {
        throw new ModelException(x);
      }
      catch (InvocationTargetException x)
      {
        throw new ModelException(x.getTargetException());
      }
    }
    else if (query.getName() != null)
    {
      res = standardDao.findByNamedQuery(query.getName(), queryParams, firstResult, maxResults, listing
              .getSortColumnName(), listing.getSortOrder());
    }
    else
    {
      res = standardDao.findByQuery(query.getQuery(), queryParams, firstResult, maxResults, listing
              .getSortColumnName(), listing.getSortOrder());
    }

    int rowNum = 1;

    for (Object row : res)
    {
      context.setIt(row);

      Output outItem = response.createOutput("item");

      outList.add(outItem);

      String idExpression = listing.getIdColumn();

      if (idExpression == null)
      {
        idExpression = "#{it.id}";
      }

      String id = ExpressionLanguageContext.evalExpressionLanguageValue(context, request, idExpression)
              .toString();

      try
      {
        outItem.setAttribute("id", id);
      }
      catch (Exception x)
      {
        throw new ModelException("Unable to retrieve id property in listing '" + listing.getId() + "' ("
                + x.getMessage() + ")");
      }

      outItem.setAttribute("odd", new Boolean(rowNum % 2 == 1));
      outItem.setAttribute("even", new Boolean(rowNum % 2 == 0));
View Full Code Here

        }
      }
      catch (SQLException x)
      {
        System.out.println("[ListTools] SQLError: " + x);
        throw new ModelException("[ListTools] SQLError " + x);
      }
      finally
      {
        DbUtils.closeQuietly(set);
        DbUtils.closeQuietly(stmt);
View Full Code Here

    StringBuffer sql = new StringBuffer("SELECT ");
    PersistentMetaData idPersistentMeta = persistents.getMetaData(listing.getIdPersistent());

    if (idPersistentMeta == null)
    {
      throw new ModelException("ListTools: Unknown persistent specified for id column '" + listing.getIdColumn()
              + "'");
    }

    if (listing.getNumIdColumns() == 1)
    {
      sql.append(listing.getIdPersistent() + "." + idPersistentMeta.getDBFieldName(listing.getIdField())
              + " AS id");
    }
    else
    {
      int col = 1;

      for (Iterator i = listing.getIdColumns().iterator(); i.hasNext();)
      {
        ListingDescriptor.IdColumnInfo idInfo = (ListingDescriptor.IdColumnInfo) i.next();

        if (col > 1)
        {
          sql.append(", ");
        }

        sql
                .append(idInfo.persistent + "." + idPersistentMeta.getDBFieldName(idInfo.field)
                        + " AS id" + (col++));
      }
    }

    for (Iterator i = listing.columnIterator(); i.hasNext();)
    {
      ColumnDescriptor column = (ColumnDescriptor) i.next();

      if ("custom".equals(column.getViewer()) || column.getViewer().startsWith("js:"))
      {
        continue;
      }

      sql.append(", ");

      PersistentMetaData columnPersistentMeta = persistents.getMetaData(column.getPersistent());

      if (columnPersistentMeta == null)
      {
        throw new ModelException("ListTools: Unknown persistent specified for column '" + column.getName()
                + "'");
      }

      sql.append(column.getPersistent() + "." + columnPersistentMeta.getDBFieldName(column.getField()) + " AS "
              + column.getAs());
View Full Code Here

    StringBuffer sql = new StringBuffer("");
    Iterator iKey = persistents.keyIterator();

    if (! iKey.hasNext())
    {
      throw new ModelException("No persistents defined for listing " + listing.getHeader());
    }

    String key = (String) iKey.next();
    PersistentMetaData persistentMeta = persistents.getMetaData(key);

    sql.append(" FROM " + persistentMeta.getTableName() + " AS " + key);

    for (; iKey.hasNext();)
    {
      key = (String) iKey.next();
      persistentMeta = persistents.getMetaData(key);
      sql.append(" LEFT JOIN " + persistentMeta.getTableName() + " AS " + key + " ON ");

      PersistentDescriptor.JoinInfo join = persistents.getJoin(key);

      if (join == null)
      {
        throw new ModelException("ListTools: No join info defined for persistent '" + key + "'");
      }

      PersistentMetaData persistentMetaJoin = persistents.getMetaData(join.getPersistent());

      sql.append(join.getPersistent() + "." + persistentMetaJoin.getDBFieldName(join.getKey()) + " = " + key
View Full Code Here

          ue = new DefaultUserEnvironment();
          ((DefaultContext) c).put(UserEnvironment.CONTEXT_KEY, ue);
        }
        else
        {
          throw new ModelException("Unable to write user env. to context, was '" + c.getClass().getName());
        }
      }

      authMgr.login(ue);

      try
      {
        HashMap cookies = new HashMap();

        if (remember)
        {
          String[] cookieSeq = getCryptSeq(configuration, "cookie");
          cookies.put(getLoginCookieName(configuration), encodeWithSeq(cookieSeq, loginName, req));
          cookies.put(getPasswordCookieName(configuration), encodeWithSeq(cookieSeq, providedPassword, req));
          cookies.put(getDomainCookieName(configuration), encodeWithSeq(cookieSeq, domain, req));
          res.addOutput("remembered", "$loginRemembered");
        }
        else
        {
          cookies.put(getLoginCookieName(configuration), "");
          cookies.put(getPasswordCookieName(configuration), "");
          cookies.put(getDomainCookieName(configuration), "");
          res.addOutput("remembered", "$loginNotRemembered");
        }

        res.setAttribute("cookies", cookies);
      }
      catch (ModelException e)
      {
        throw new LoginException("Error setting cookies - " + e.getMessage());
      }

      if (log.isDebugEnabled())
      {
        log.debug("Logged in authenticated user: " + loginName + " domain: " + domain);
        log.debug("\tPrincipals:");

        Iterator i = ue.getSubject().getPrincipals().iterator();
        while (i.hasNext())
        {
          Principal p = (Principal) i.next();
          log.debug(p.toString());
        }
      }
    }
    catch (LoginException e)
    {
      if (e.getMessage().matches(".*([Ll]ogin|[Aa]ccount).*"))
      {
        res.addError("GLOBAL_loginError", "$badLoginName");
      }
      else if (e.getMessage().matches(".*[Pp]assword.*"))
      {
        res.addError("GLOBAL_loginError", "$badPassword");
      }
      else
      {
        res.addError("GLOBAL_loginError", "$loginError");
      }

      log.warn("Login error for user '" + loginName + "': " + e.getMessage());

      return res.createCommand(Constants.PROMPT_LOGIN).execute(req, res);
    }
    catch (Exception dbe)
    {
      res.addError("GLOBAL_loginError", dbe);
      log.error("loginError", dbe);

      return res.createCommand(Constants.PROMPT_LOGIN).execute(req, res);
    }

    try
    {
      log.debug(loginName + " logged in successfully");

      res.addCommand(Constants.LOGOFF, "Log Off");
    }
    catch (Exception x)
    {
      log.error("Login Error", x);
      throw new ModelException(x);
    }

    if (res.getErrors().size() == 0)
    {
      Properties props = new Properties();
View Full Code Here

TOP

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

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.