@Override public int hashCode() { int hash = 7; hash = 53 * hash + this.getId(); hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 53 * hash + (this.shortName != null ? this.shortName.hashCode() : 0); return hash; }
@Override public String serializeToString() { StringBuilder str = new StringBuilder(); return str.append(this.getClass().getSimpleName()).append(":[").append( "id=<").append(getId()).append(">").append( ", name=<").append(getName() == null ? "\\0" : BeansUtils.createEscaping(getName())).append(">").append( ", shortName=<").append(getShortName() == null ? "\\0" : BeansUtils.createEscaping(getShortName())).append(">").append( ']').toString(); }
private static Vo createVo(Map<String, String> beanAttr) { if(beanAttr==null) return null; Vo vo = new Vo(); vo.setId(Integer.valueOf(beanAttr.get("id"))); vo.setName(BeansUtils.eraseEscaping(beanAttr.get("name"))); vo.setShortName(BeansUtils.eraseEscaping(beanAttr.get("shortName"))); return vo; }
@Override public int compareTo(PerunBean perunBean) { if(perunBean == null) throw new NullPointerException("PerunBean to compare with is null."); if(perunBean instanceof Vo) { Vo vo = (Vo) perunBean; if (this.getName() == null && vo.getName() != null) return -1; if (vo.getName() == null && this.getName() != null) return 1; if (this.getName() == null && vo.getName() == null) return 0; return this.getName().compareToIgnoreCase(vo.getName()); } else { return (this.getId() - perunBean.getId()); } }
/** * Replace link for mail invitation not concerning authz type * * @param vo vo to get invite link for * @param group group if is for group application * @param text base of URL for invitation * @return full URL to application form */ private String buildInviteURL(Vo vo, Group group, String text) { if (text == null || text.isEmpty()) return ""; text += "?vo=" + getEncodedString(vo.getShortName()); if (group != null) { // application for group too text += "&group="+getEncodedString(group.getName()); } return text; }
throw new RegistrarException("User to invite is already member of your VO:"+vo.getShortName()); log.error("[MAIL MANAGER] Exception throw when getting member by {} from {}: {}", user, vo.toString(), ex);
mailText = mailText.replace("{voName}", vo.getName());
@Override public Application mapRow(ResultSet rs, int i) throws SQLException { Application app = new Application(rs.getInt("id"), new Vo(rs.getInt("vo_id"), rs.getString("vo_name"), rs.getString("vo_short_name"), rs.getString("vo_created_at"), rs.getString("vo_created_by"),
public VoNotExistsException(Vo vo) { super(vo.toString()); this.vo = vo; }
@Override public ApplicationForm getFormForVo(final Vo vo) throws PerunException { if (vo == null) throw new InternalErrorException("VO can't be null"); try { return jdbc.queryForObject(FORM_SELECT + " where vo_id=? and group_id is null", new RowMapper<ApplicationForm>() { @Override public ApplicationForm mapRow(ResultSet rs, int arg1) throws SQLException { ApplicationForm form = new ApplicationForm(); form.setId(rs.getInt("id")); form.setAutomaticApproval(rs.getBoolean("automatic_approval")); form.setAutomaticApprovalExtension(rs.getBoolean("automatic_approval_extension")); form.setModuleClassName(rs.getString("module_name")); form.setVo(vo); return form; } }, vo.getId()); } catch (EmptyResultDataAccessException ex) { throw new FormNotExistsException("Form for VO: "+vo.getName()+" doesn't exists."); } }
if (!text.endsWith("/")) text += "/"; text += "registrar/"; text += "?vo=" + getEncodedString(vo.getShortName()) + "&page=apps"; if (!newValue.endsWith("/")) newValue += "/"; newValue += namespace + "/registrar/"; newValue += "?vo="+getEncodedString(vo.getShortName()); newValue += ((group != null) ? "&group="+getEncodedString(group.getName()) : ""); newValue += "&page=apps";
mailText = mailText.replace("{voName}", app.getVo().getName());
@Override public String toString() { StringBuilder str = new StringBuilder(); return str.append(this.getClass().getSimpleName()).append(":[").append( "id='").append(this.getId()).append('\'').append( ", name='").append(name).append('\'').append( ", shortName='").append(shortName).append('\'').append( ']').toString(); }
dn+= "perunVoId=" + vo.getId() + "," + ldapBase; writer.write(dn + '\n'); desc+= vo.getName(); writer.write(desc + '\n'); o+= vo.getShortName(); writer.write(o + '\n'); perunVoId+= String.valueOf(vo.getId()); writer.write(perunVoId + '\n');
regs.addAll(jdbc.query("select id from application where apptype=? and vo_id=? and group_id=? and state=? and (user_id=? or (created_by=? and extSourceName=?))", new SingleColumnRowMapper<Integer>(Integer.class), AppType.INITIAL.toString(), vo.getId(), group.getId(), AppState.NEW.toString(), user.getId(), actor, extSourceName)); regs.addAll(jdbc.query("select id from application where apptype=? and vo_id=? and group_id=? and state=? and (user_id=? or (created_by=? and extSourceName=?))", new SingleColumnRowMapper<Integer>(Integer.class), AppType.INITIAL.toString(), vo.getId(), group.getId(), AppState.VERIFIED.toString(), user.getId(), actor, extSourceName)); if (!regs.isEmpty()) { throw new AlreadyRegisteredException("You are already member of VO: "+vo.getName()); regs.addAll(jdbc.query("select id from application where apptype=? and vo_id=? and group_id=? and state=? and (user_id=? or (created_by=? and extSourceName=?))", new SingleColumnRowMapper<Integer>(Integer.class), AppType.INITIAL.toString(), vo.getId(), group.getId(), AppState.NEW.toString(), user.getId(), actor, extSourceName)); regs.addAll(jdbc.query("select id from application where apptype=? and vo_id=? and group_id=? and state=? and (user_id=? or (created_by=? and extSourceName=?))", new SingleColumnRowMapper<Integer>(Integer.class), AppType.INITIAL.toString(), vo.getId(), group.getId(), AppState.VERIFIED.toString(), user.getId(), actor, extSourceName)); if (!regs.isEmpty()) { regs.addAll(jdbc.query("select id from application where apptype=? and vo_id=? and group_id is null and state=? and (user_id=? or (created_by=? and extSourceName=?))", new SingleColumnRowMapper<Integer>(Integer.class), AppType.INITIAL.toString(), vo.getId(), AppState.NEW.toString(), user.getId(), actor, extSourceName)); regs.addAll(jdbc.query("select id from application where apptype=? and vo_id=? and group_id is null and state=? and (user_id=? or (created_by=? and extSourceName=?))", new SingleColumnRowMapper<Integer>(Integer.class), AppType.INITIAL.toString(), vo.getId(), AppState.VERIFIED.toString(), user.getId(), actor, extSourceName)); if (!regs.isEmpty()) { throw new DuplicateRegistrationAttemptException("Initial application for VO: "+vo.getName()+" already exists.", actor, extSourceName, regs.get(0)); AppType.INITIAL.toString(), vo.getId(), group.getId(), actor, extSourceName, AppState.APPROVED.toString(), AppState.REJECTED.toString()));
result.add(group); Vo vo = new Vo(); vo.setId(165684); vo.setName("AttributesManagerTestVo"); vo.setShortName("AMTVO"); result.add(vo);
/** * This method creates groups used by VOOT, that are represented to end-user. They are created from groups by provider. * * @param groups groups from provider * @return array of groups, that are represented to end-user * @throws VOOTException if can not read groups by provider */ private VOOTGroup[] createVOOTGroups(List<Group> groups) throws VOOTException{ GroupsManagerBl groupManager = perun.getGroupsManagerBl(); VOOTGroup[] vootGroups = new VOOTGroup[groups.size()]; int i=0; for(Group group : groups){ String vootMembership; try{ if(groupManager.getAdmins(session, group).contains(user)){ vootMembership = "admin"; } else{ vootMembership = "member"; } vootGroups[i] = new VOOTGroup (group, groupManager.getVo(session, group).getShortName(), vootMembership); i++; }catch(InternalErrorException ex){ throw new VOOTException("internal_server_error"); } } return vootGroups; }
Map<LdapOperation, List<Pair<String,String>>> attributes = new HashMap<LdapOperation, List<Pair<String, String>>>(); List<Pair<String,String>> replaceList = new ArrayList<Pair<String, String>>(); replaceList.add(new Pair(ldapAttrDescription,this.vo.getName())); attributes.put(LdapOperation.REPLACE_ATTRIBUTE, replaceList); updateVoAttributes(attributes, this.vo);
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Vo other = (Vo) obj; if (this.getId() != other.getId()) { return false; } if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { return false; } if ((this.shortName == null) ? (other.shortName != null) : !this.shortName.equals(other.shortName)) { return false; } return true; } }
public void createVo(Vo vo) throws InternalErrorException { // Create a set of attributes for vo Attributes voAttributes = new BasicAttributes(); // Create the objectclass to add Attribute voObjClasses = new BasicAttribute(EventProcessorImpl.ldapAttrObjectClass); voObjClasses.add(EventProcessorImpl.objectClassTop); voObjClasses.add(EventProcessorImpl.objectClassOrganization); voObjClasses.add(EventProcessorImpl.objectClassPerunVO); // Add attributes voAttributes.put(voObjClasses); voAttributes.put(EventProcessorImpl.ldapAttrOrganization, vo.getShortName()); voAttributes.put(EventProcessorImpl.ldapAttrDescription, vo.getName()); voAttributes.put(EventProcessorImpl.ldapAttrPerunVoId, String.valueOf(vo.getId())); // Create the entires try { ldapTemplate.bind(getVoDNByVoId(String.valueOf(vo.getId())), null, voAttributes); log.debug("New entry created in LDAP: Vo {}.", vo); } catch (NameNotFoundException e) { throw new InternalErrorException(e); } }