public SDMSGroup create(SystemEnvironment env, String p_name, Long p_deleteVersion)
      throws SDMSException {
    Long p_creatorUId = env.cEnv.uid();
    Long p_createTs = env.txTime();
    Long p_changerUId = env.cEnv.uid();
    Long p_changeTs = env.txTime();

    if (env.tx.mode == SDMSTransaction.READONLY) {

      throw new FatalException(new SDMSMessage(env, "01110182049", "Group"));
    }
    validate(env, p_name, p_deleteVersion, p_creatorUId, p_createTs, p_changerUId, p_changeTs);

    env.tx.beginSubTransaction(env);
    SDMSGroupGeneric o =
        new SDMSGroupGeneric(
            env, p_name, p_deleteVersion, p_creatorUId, p_createTs, p_changerUId, p_changeTs);

    SDMSGroup p;
    try {
      env.tx.addToChangeSet(env, o.versions, true);
      env.tx.addToTouchSet(env, o.versions, true);
      table.put(env, o.id, o.versions);
      env.tx.commitSubTransaction(env);
      p = (SDMSGroup) (o.toProxy());
      p.current = true;
    } catch (SDMSException e) {
      p = (SDMSGroup) (o.toProxy());
      p.current = true;
      env.tx.rollbackSubTransaction(env);
      throw e;
    }

    if (!checkCreatePrivs(env, p))
      throw new AccessViolationException(p.accessViolationMessage(env, "01402270738"));

    return p;
  }
  protected boolean checkCreatePrivs(SystemEnvironment env, SDMSGroup p) throws SDMSException {
    if (!p.checkPrivileges(env, SDMSPrivilege.CREATE)) return false;

    return true;
  }
示例#3
0
  public void go(SystemEnvironment sysEnv) throws SDMSException {
    Long sgId = null;
    Long ZERO = new Long(0);

    if (!sysEnv.cEnv.gid().contains(SDMSObject.adminGId)) {
      SDMSPrivilege p = new SDMSPrivilege();
      Vector v = SDMSMemberTable.idx_uId.getVector(sysEnv, sysEnv.cEnv.uid());
      for (int i = 0; i < v.size(); i++) {
        SDMSMember m = (SDMSMember) v.get(i);
        try {
          SDMSGrant gr =
              SDMSGrantTable.idx_objectId_gId_getUnique(
                  sysEnv, new SDMSKey(ZERO, m.getGId(sysEnv)));
          p.addPriv(sysEnv, gr.getPrivs(sysEnv).longValue());
        } catch (NotFoundException nfe) {

        }
      }
      try {
        if (sysEnv.selectGroup != null) {
          SDMSGroup sg = SDMSGroupTable.idx_name_getUnique(sysEnv, sysEnv.selectGroup);
          sgId = sg.getId(sysEnv);
        }
      } catch (NotFoundException nfe) {

      }
      if (!(p.can(SDMSPrivilege.MANAGE_SEL) || (sgId != null && sysEnv.cEnv.gid().contains(sgId))))
        throw new AccessViolationException(
            new SDMSMessage(sysEnv, "03003081235", "Insufficient Privileges"));
    }

    int read = 0;
    SDMSOutputContainer d_container = null;

    if (cl_size > 0) {
      clist = new int[cl_size];
      ctype = new int[cl_size];
    }

    try {
      Statement stmt = sysEnv.dbConnection.createStatement();
      ResultSet rset = stmt.executeQuery(selectCmd);
      ResultSetMetaData mdset = rset.getMetaData();
      Vector desc = collist(mdset);
      d_container = new SDMSOutputContainer(sysEnv, "Selected Values", desc);
      while (rset.next()) {
        Vector data = new Vector();
        int j = 0;
        for (int i = 1; i <= desc.size(); i++) {
          Object o = rset.getObject(i);
          if (cl_size > 0 && j < cl_size && i == clist[j]) {
            o = convert(sysEnv, o, j);
            j++;
          }
          data.addElement((rset.wasNull() ? null : o));
        }
        d_container.addData(sysEnv, data);
        read++;
      }
      stmt.close();
      sysEnv.dbConnection.commit();
    } catch (SQLException sqle) {

      try {

        sysEnv.dbConnection.rollback();
      } catch (SQLException sqle2) {

        throw new RecoverableException(new SDMSMessage(sysEnv, "03310281524", "Connection lost"));
      }

      throw new CommonErrorException(
          new SDMSMessage(sysEnv, "03204170024", "SQL Error : $1", sqle.toString()));
    }

    if (sv != null && sv.size() > 0) {
      int sca[] = new int[sv.size()];
      for (int i = 0; i < sv.size(); i++) {
        sca[i] = ((Integer) sv.get(i)).intValue();
        if (sca[i] >= d_container.columns)
          throw new CommonErrorException(
              new SDMSMessage(
                  sysEnv,
                  "03003081227",
                  "The sort column specified ($1) exceeds the number of columns in the output",
                  new Integer(sca[i])));
      }
      Collections.sort(d_container.dataset, d_container.getComparator(sysEnv, sca));
    }

    result.setOutputContainer(d_container);
    result.setFeedback(
        new SDMSMessage(sysEnv, "03204112153", "$1 Row(s) selected", new Integer(read)));
  }