示例#1
0
  public Group updateGroupName(PerunSession sess, Group group) throws InternalErrorException {
    Utils.notNull(group.getName(), "group.getName()");

    // Get the group stored in the DB
    Group dbGroup;
    try {
      dbGroup = this.getGroupById(sess, group.getId());
    } catch (GroupNotExistsException e) {
      throw new InternalErrorException("Group existence was checked at the higher level", e);
    }

    if (!dbGroup.getName().equals(group.getName())) {
      dbGroup.setName(group.getName());
      try {
        jdbc.update(
            "update groups set name=?,modified_by=?, modified_by_uid=?, modified_at="
                + Compatibility.getSysdate()
                + " where id=?",
            dbGroup.getName(),
            sess.getPerunPrincipal().getActor(),
            sess.getPerunPrincipal().getUserId(),
            dbGroup.getId());
      } catch (RuntimeException e) {
        throw new InternalErrorException(e);
      }
    }
    return dbGroup;
  }
示例#2
0
 private static Group createGroup(Map<String, String> beanAttr) {
   if (beanAttr == null) return null;
   Group group = new Group();
   if (beanAttr.get("parentGroupId").equals("\\0")) group.setParentGroupId(null);
   else group.setParentGroupId(Integer.valueOf(beanAttr.get("parentGroupId")));
   group.setId(Integer.valueOf(beanAttr.get("id")).intValue());
   group.setName(BeansUtils.eraseEscaping(beanAttr.get("name")));
   group.setDescription(BeansUtils.eraseEscaping(beanAttr.get("description")));
   group.setVoId(Integer.valueOf(beanAttr.get("voId")));
   return group;
 }
示例#3
0
  /*
   * Create a subgroup
   *
   * @see cz.metacentrum.perun.core.implApi.GroupsManagerImplApi#createGroup(cz.metacentrum.perun.core.api.PerunSession, cz.metacentrum.perun.core.api.Vo, cz.metacentrum.perun.core.api.Group, cz.metacentrum.perun.core.api.Group)
   */
  public Group createGroup(PerunSession sess, Vo vo, Group parentGroup, Group group)
      throws GroupExistsException, InternalErrorException {
    // Create new subGroup

    group.setParentGroupId(parentGroup.getId());

    group.setName(parentGroup.getName() + ":" + group.getShortName());

    group = createGroup(sess, vo, group);

    return group;
  }
示例#4
0
 public Group mapRow(ResultSet rs, int i) throws SQLException {
   Group g = new Group();
   g.setId(rs.getInt("groups_id"));
   // ParentGroup with ID=0 is not supported
   if (rs.getInt("groups_parent_group_id") != 0)
     g.setParentGroupId(rs.getInt("groups_parent_group_id"));
   else g.setParentGroupId(null);
   g.setName(rs.getString("groups_name"));
   g.setShortName(g.getName().substring(g.getName().lastIndexOf(":") + 1));
   g.setDescription(rs.getString("groups_dsc"));
   g.setVoId(rs.getInt("groups_vo_id"));
   g.setCreatedAt(rs.getString("groups_created_at"));
   g.setCreatedBy(rs.getString("groups_created_by"));
   g.setModifiedAt(rs.getString("groups_modified_at"));
   g.setModifiedBy(rs.getString("groups_modified_by"));
   if (rs.getInt("groups_modified_by_uid") == 0) g.setModifiedByUid(null);
   else g.setModifiedByUid(rs.getInt("groups_modified_by_uid"));
   if (rs.getInt("groups_created_by_uid") == 0) g.setCreatedByUid(null);
   else g.setCreatedByUid(rs.getInt("groups_created_by_uid"));
   return g;
 }