@Override public String serializeToString() { StringBuilder str = new StringBuilder(); return str.append(this.getClass().getSimpleName()).append(":[").append( "id=<").append(getId()).append(">").append( ", parentGroupId=<").append(getParentGroupId() == null ? "\\0" : getParentGroupId()).append(">").append( ", name=<").append(getName() == null ? "\\0" : BeansUtils.createEscaping(getName())).append(">").append( ", shortName=<").append(getShortName() == null ? "\\0" : BeansUtils.createEscaping(getShortName())).append(">").append( ", description=<").append(getDescription() == null ? "\\0" : BeansUtils.createEscaping(getDescription())).append(">").append( ", voId=<").append(getVoId()).append(">").append( ']').toString(); }
/** * VOOTGroup represents group encoded according to the OpenSocial Social Data Specification using in VOOT protocol. * * @param group group * @param voShortName short name of vo * @param voot_membership_role membership role of person in group */ public VOOTGroup(Group group, String voShortName, String voot_membership_role) throws VOOTException{ //group must be in vo if(voShortName == null) throw new VOOTException("internal_error_exception"); this.id = voShortName.concat(":").concat(group.getName()); this.title = group.getName(); this.description = group.getDescription(); this.voot_membership_role = voot_membership_role; }
/** * Update basic group attributes (name and description) in LDAP * * @param group group after update * * @throws InternalErrorException */ private void updateGroup(Group group) throws InternalErrorException { Map<LdapOperation, List<Pair<String,String>>> attributes = new HashMap<>(); List<Pair<String,String>> listAttributesToBeRemoved = new ArrayList<>(); List<Pair<String,String>> listAttributesToBeReplaced = new ArrayList<>(); //change name listAttributesToBeReplaced.add(new Pair(ldapAttrCommonName,this.group.getName())); listAttributesToBeReplaced.add(new Pair(ldapAttrPerunUniqueGroupName, ldapConnector.getVoShortName(this.group.getVoId()) + ":" + this.group.getName())); //change description (or remove it if there is none) if(group.getDescription() != null && !group.getDescription().isEmpty()) { listAttributesToBeReplaced.add(new Pair(ldapAttrDescription, this.group.getDescription())); } else { if(ldapConnector.groupAttributeExist(group, ldapAttrDescription)) { listAttributesToBeRemoved.add(new Pair(ldapAttrDescription, null)); } } //Add all attributes which will be replaced for the group (that also mean added if not exists yet) attributes.put(LdapOperation.REPLACE_ATTRIBUTE, listAttributesToBeReplaced); //Add all attributes (if any) which will be removed for group if(!listAttributesToBeReplaced.isEmpty()) attributes.put(LdapOperation.REMOVE_ATTRIBUTE, listAttributesToBeRemoved); //update attributes in LDAP for group updateGroupAttributes(attributes, group); }
public void addGroup(Group group) throws InternalErrorException { // Create a set of attributes Attributes attributes = new BasicAttributes(); // Create the objectclass to add Attribute objClasses = new BasicAttribute(EventProcessorImpl.ldapAttrObjectClass); objClasses.add(EventProcessorImpl.objectClassTop); objClasses.add(EventProcessorImpl.objectClassPerunGroup); // Add attributes attributes.put(objClasses); attributes.put(EventProcessorImpl.ldapAttrCommonName, group.getName()); attributes.put(EventProcessorImpl.ldapAttrPerunGroupId, String.valueOf(group.getId())); attributes.put(EventProcessorImpl.ldapAttrPerunUniqueGroupName, new String(this.getVoShortName(group.getVoId()) + ":" + group.getName())); attributes.put(EventProcessorImpl.ldapAttrPerunVoId, String.valueOf(group.getVoId())); if(group.getDescription() != null && !group.getDescription().isEmpty()) attributes.put(EventProcessorImpl.ldapAttrDescription, group.getDescription()); if(group.getParentGroupId() != null) { attributes.put(EventProcessorImpl.ldapAttrPerunParentGroup, EventProcessorImpl.ldapAttrPerunGroupId + "=" + group.getParentGroupId().toString() + "," + EventProcessorImpl.ldapAttrPerunVoId + "=" + group.getVoId() + "," + ldapProperties.getLdapBase()); attributes.put(EventProcessorImpl.ldapAttrPerunParentGroupId, group.getParentGroupId().toString()); } // Create the entry try { ldapTemplate.bind(getGroupDN(String.valueOf(group.getVoId()), String.valueOf(group.getId())), null, attributes); log.debug("New entry created in LDAP: Group {} in Vo with Id=" + group.getVoId() + ".", group); } catch (NameNotFoundException e) { throw new InternalErrorException(e); } }
String descriptionValue = group.getDescription(); if(descriptionValue != null) { if(descriptionValue.matches("^\\s*$")) descriptionValue = null;
public RichGroup(Group group, List<Attribute> attrs) { super(group.getId(), group.getName(), group.getDescription(), group.getCreatedAt(), group.getCreatedBy(), group.getModifiedAt(), group.getModifiedBy(), group.getParentGroupId(), group.getCreatedByUid(), group.getModifiedByUid()); this.setVoId(group.getVoId()); this.groupAttributes = attrs; }