Package ru.vassaev.core.exception

Examples of ru.vassaev.core.exception.SysException


      } else if (file instanceof InputStream) {
        fr = new InputStreamReader((InputStream) file, charset);
      } else if (file instanceof java.io.Reader) {
        fr = (java.io.Reader) file;
      } else
        throw new SysException("Unsupported type of parameter ('file')");
      String[] vs;
      ArrayList<String> prms = upd.getParamNames();
      int j = 0;
      PreparedStatement st = upd.getStatement(con);
      try {
        while ((vs = Strings.parseXVSLine(fr, sysch, delch)).length > 0) {
          for (int i = prms.size() - 1; i >= 0; i--) {
            String name = prms.get(i);
            Integer ind = names.get(name);
            if ((ind != null) && (vs.length > ind)) {
              upd.setParam(st, name, vs[ind], java.sql.Types.VARCHAR);
            } else {
              upd.setParam(st, name, null, java.sql.Types.VARCHAR);
            }
          }
          st.execute();
          j++;
          if (j % 10 == 0) {
            con.commit();
          }
        }
        con.commit();
      } finally {
        upd.freeStatement(st);
      }
      return true;
    } catch (java.sql.SQLException ex) {
      throw new SysException(ex);
    } catch (IOException ex) {
      throw new SysException(ex);
    } finally {
      Manager.freeConnection(con);
    }
  }
View Full Code Here


  };

  public State paramsValidateAndPrepare(Context cntx) throws SysException {
    source = cntx.getPrmByFullName("source");
    if (Null.equ(source))
      throw new SysException("Parameter \"source\" isn't set");
    return null;
  }
View Full Code Here

          (String) this.task_api.getValue(cntx)
          : cntx.ta.getClass().getCanonicalName();
      if (task_api == null)
        task_api = cntx.ta.getClass().getCanonicalName();
    } catch (CalculateException e1) {
      throw new SysException(e1);
    }
    ITaskAPI ta = ATaskAPI.getInstance(task_api, cntx.ta.getClass(), alias);
    if (ta == null)
      ta = cntx.ta;

    long id_task;
    Context parent_context = cntx.parent;
    Long id_processor;
    if (!ta.equals(cntx.ta)) {
      id_processor = ATaskAPI.getApplicationSubject(ta);
      if (id_processor == 0L) {
        boolean waiting = true;
        do {
          try {
            id_processor = ta.getSubject(0);
            waiting = false;
          } catch (SysException e) {
            System.out.println("Waiting interface...");
            try {
              Thread.sleep(1000);// TODO нужен параметр
            } catch (InterruptedException e1) {
              throw new SysException(e1);
            }
          }
        } while (waiting);
        ATaskAPI.setApplicationSubject(ta, id_processor);
      }
    } else
      id_processor = cntx.id_subject;

    try {
      // Получить класс задания
      String cls = (String) classname.getValue(cntx);
      // Если класс задания не определен,
      if (Null.equ(cls) || cls.equals("")) {
        cntx.id_task = -1;
        return cntx;
      }
      // Создадим запись о задании
      id_task = ta
          .createTask(
              id_processor,
              cls,
              (ta.equals(cntx.ta) && parent_context != null) ? parent_context.id_task
                  : 0);

    } catch (CalculateException e) {
      throw new SysException(e);
    }
    Context res;
    if (ta.equals(cntx.ta)) {
      res = cntx;
      res.id_task = id_task;
    } else
      res = new Context(parent_context, id_processor, id_task, ta, this);

    Set<Entry<String, Object>> s = prms.entrySet();
    for (Entry<String, Object> x : s)
      try {
        Object v = x.getValue();
        if (Null.equ(v))
          continue;
        String name = x.getKey();
        if (v instanceof IDependentParam) {
          IDependentParam d = (IDependentParam) v;
          if (!d.isNoSave()) {
            TimeList tl = cntx.getTimeList(d.getGLName(), d);
            Object vl = d.getValue(cntx);
            if (Null.equ(vl))
              continue;
            long wait = tl.getWaitTime();
            long calc = tl.getWorkTime();
            long sc = tl.getSystemCallTime();
            // ta.setTaskParamObject(id_task, x.getKey(),
            // d.getValue(cntx));
            ta.setParamObject(id_task, name, vl, wait, calc, sc);
          }
        } else {
          // ta.setTaskParamString(id_task, x.getKey(), v.toString());
          ta.setParamObject(id_task, name, v);
        }
      } catch (CalculateException e) {
        throw new SysException(e);
      }
    // Установить доп. параметры в задании
    if (!Null.equ(addprms))
      if (addprms instanceof Map) {
        Map<String, Object> aprms = (Map<String, Object>) addprms;
        for (Entry<String, Object> e : aprms.entrySet()) {
          String n = (grp == null) ? e.getKey() : grp + "/"
              + e.getKey();
          // ta.setTaskParamObject(id_task, n, e.getValue());
          ta.setParamObject(id_task, n, e.getValue());
        }
      } else if (addprms instanceof PrmInterface) {
        PrmInterface aprms = (PrmInterface) addprms;
        for (String k : aprms.getFieldNames()) {
          String n = (grp == null) ? k : grp + "/" + k;
          // ta.setTaskParamString(id_task, n, aprms.getField(k));
          ta.setParamObject(id_task, n, aprms.getField(k));
        }
      } else if (addprms instanceof ByteMsg) {
        ByteMsg msg = (ByteMsg) addprms;
        PrmInterface aprms = msg.getPrmInterface();
        for (String k : aprms.getFieldNames()) {
          String n = (grp == null) ? k : grp + "/" + k;
          // ta.setTaskParamString(id_task, n, aprms.getField(k));
          ta.setParamObject(id_task, n, aprms.getField(k));
        }
      }
    try {
      String finish_duration = Strings
          .getString((this.finish_duration != null) ? this.finish_duration
              .getValue(cntx) : null);
      String block_duration = Strings
          .getString((this.block_duration != null) ? this.block_duration
              .getValue(cntx) : null);
      Double arch_day = Strings
          .parseDouble((this.arch_day != null) ? this.arch_day
              .getValue(cntx) : null);
      ta.setTaskDT(id_task, null, finish_duration, block_duration,
          arch_day);
      // Будет обрабатывать текущий обработчик?
      if (this.processor_id != null)
        res.id_task = ta.setReady(id_processor, id_task,
            Strings.parseLong(processor_id.getValue(cntx)));
      else
        res.id_task = ta.setReady(id_processor, id_task, null);
      return res;
    } catch (CalculateException e) {
      throw new SysException(e);
    }
  }
View Full Code Here

        if (prc.isWillBreak())
          return;
        Thread.sleep(2000);//!!!
      }
    } catch (InterruptedException e1) {
      throw new SysException(e1);
    } finally {
      if (server != null)
        server.stop(0);
    }
View Full Code Here

 
  public Env(center.task.prm.Type tp, String owner, Element e) throws SysException {
    super(tp, owner);
    env_name = Prm.getPrm(e);
    if (Null.equ(env_name))
      throw new SysException("The environment in param '" + owner + "' hasn't name");
  }
View Full Code Here

  private PoolThread executor = null;

  public void paramsValidateAndPrepare(Context cntx) throws SysException {
    port = Strings.parseInteger(cntx.getPrmString("port"));
    if (port == null)
      throw new SysException("Parameter port isn't set");
    https = Strings.parseBooleanNvl(cntx.getPrmString("https"), false);
    if (https) {
      story_file = cntx.getPrmString("story_file");
      if (story_file == null)
        throw new SysException("Parameter story_file isn't set");
      if (File.separatorChar != '\\')
        story_file = story_file.replace('\\', File.separatorChar);
      if (File.separatorChar != '/')
        story_file = story_file.replace('/', File.separatorChar);
      File sf = new File(story_file);
      try {
        story_file = sf.getCanonicalPath();
      } catch (IOException e) {
        throw new SysException(e);
      }
      String story_pwd = cntx.getPrmString("story_pwd");
      if (story_pwd == null)
        throw new SysException("Parameter story_pwd isn't set");
      this.story_pwd = story_pwd.toCharArray();
      String key_pwd = cntx.getPrmString("key_pwd");
      if (key_pwd == null)
        throw new SysException("Parameter key_pwd isn't set");
      this.key_pwd = key_pwd.toCharArray();
    }
    path = cntx.getPrmString("path");
    if (path == null)
      path = "/";
    String poolProcessName = cntx.getPrmString("process_pool");
    if (Null.equ(poolProcessName))
      throw new SysException("Parameter process_pool isn't set");
    executor = (PoolThread) ApplicationManager.getPoolByName(poolProcessName, Process.class);
  }
View Full Code Here

          ex.printStackTrace();
          attempt--;
          if (attempt > 0) {
            con = Manager.reInitConnection(con);
          } else
            throw new SysException(ex);
        } catch (Exception ex) {
          throw new SysException(ex);
        }
    } catch (Exception ex) {
      throw new SysException(ex);
    } finally {
      Manager.freeConnection(con);
    }
  }
View Full Code Here

          ex.printStackTrace();
          attempt--;
          if (attempt > 0) {
            con = Manager.reInitConnection(con);
          } else
            throw new SysException(ex);
        } catch (Exception ex) {
          throw new SysException(ex);
        }
    } finally {
      Manager.freeConnection(con);
    }
  }
View Full Code Here

          ex.printStackTrace();
          attempt--;
          if (attempt > 0) {
            con = Manager.reInitConnection(con);
          } else
            throw new SysException(ex);
        } catch (Exception ex) {
          throw new SysException(ex);
        }
    } finally {
      Manager.freeConnection(con);
    }
  }
View Full Code Here

      } finally {
        stmtGetNow.freeStatement(now);
      }
      return tm;
    } catch (SQLException ex) {
      throw new SysException(ex);
    } catch (Exception ex) {
      throw new SysException(ex);
    }
  }
View Full Code Here

TOP

Related Classes of ru.vassaev.core.exception.SysException

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.