@Override public String serializeToString() { StringBuilder str = new StringBuilder(); return str.append(this.getClass().getSimpleName()).append(":[").append( "id=<").append(getId()).append(">").append( ", voId=<").append(getVoId()).append(">").append( ", facilityId=<").append(getFacilityId()).append(">").append( ", name=<").append(getName() == null ? "\\0" : BeansUtils.createEscaping(getName())).append(">").append( ", description=<").append(getDescription() == null ? "\\0" : BeansUtils.createEscaping(getDescription())).append(">").append( ']').toString(); }
@Override public String toString() { StringBuilder str = new StringBuilder(); return str.append(getClass().getSimpleName()).append(":[" ).append("id='").append(getId() ).append("', voId='").append(super.getVoId() ).append("', facilityId='").append(super.getFacilityId() ).append("', name='").append(super.getName() ).append("', description='").append(super.getDescription() ).append("', facility='").append(getFacility() ).append("', vo='").append(getVo() ).append("', resourceTags='").append(getResourceTags() ).append("']").toString(); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Resource other = (Resource) obj; if (this.getId() != other.getId()) { return false; } if (this.name == null ? other.getName() != null : !this.name.equals(other.getName())) { return false; } if (this.description == null ? other.getDescription() != null : !this.description.equals(other.getDescription())) { return false; } return true; }
@Override public String serializeToString() { StringBuilder str = new StringBuilder(); String tags = "\\0"; if (getResourceTags() != null && !getResourceTags().isEmpty()) { ArrayList<String> list = new ArrayList<String>(); for (ResourceTag t : getResourceTags()) { list.add(t.serializeToString()); } tags = list.toString(); } return str.append(this.getClass().getSimpleName()).append(":[").append( "id=<").append(getId()).append(">").append( ", voId=<").append(getVoId()).append(">").append( ", facilityId=<").append(getFacilityId()).append(">").append( ", name=<").append(super.getName() == null ? "\\0" : BeansUtils.createEscaping(super.getName())).append(">").append( ", description=<").append(super.getDescription() == null ? "\\0" : BeansUtils.createEscaping(super.getDescription())).append(">").append( ", facility=<").append(getFacility() == null ? "\\0" : getFacility().serializeToString()).append(">").append( ", vo=<").append(getVo() == null ? "\\0" : getVo().serializeToString()).append(">").append( ", resourceTags=<").append(tags).append(">").append( ']').toString(); }
public void createResource(Resource resource, String entityID) 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.objectClassPerunResource); // Add attributes attributes.put(objClasses); attributes.put(EventProcessorImpl.ldapAttrCommonName, resource.getName()); attributes.put(EventProcessorImpl.ldapAttrPerunResourceId, String.valueOf(resource.getId())); attributes.put(EventProcessorImpl.ldapAttrPerunFacilityId, String.valueOf(resource.getFacilityId())); attributes.put(EventProcessorImpl.ldapAttrPerunVoId, String.valueOf(resource.getVoId())); if(resource.getDescription() != null && !resource.getDescription().isEmpty()) attributes.put(EventProcessorImpl.ldapAttrDescription, resource.getDescription()); // get info about entityID attribute if exists if(entityID != null) attributes.put(EventProcessorImpl.ldapAttrEntityID, entityID); // Create the entry try { ldapTemplate.bind(getResourceDN(String.valueOf(resource.getVoId()), String.valueOf(resource.getId())), null, attributes); log.debug("New entry created in LDAP: Resource {} in Vo with Id=" + resource.getVoId() + " and Facility with ID=" + resource.getFacilityId() + ".", resource); } catch (NameNotFoundException e) { throw new InternalErrorException(e); } }
String descriptionValue = resource.getDescription(); if(descriptionValue != null) { if(descriptionValue.matches("^\\s*$")) descriptionValue = null;
/** * Constructs a new instance. */ public RichResource(Resource resource) { super(resource.getId(), resource.getName(), resource.getDescription(), resource.getFacilityId(), resource.getVoId(), resource.getCreatedAt(), resource.getCreatedBy(), resource.getModifiedAt(), resource.getModifiedBy(), resource.getCreatedByUid(), resource.getModifiedByUid()); }
List<Pair<String,String>> replaceList = new ArrayList<>(); replaceList.add(new Pair(ldapAttrCommonName,this.resource.getName())); if(this.resource.getDescription() != null && !this.resource.getDescription().isEmpty()) replaceList.add(new Pair(ldapAttrDescription, this.resource.getDescription())); attributes.put(LdapOperation.REPLACE_ATTRIBUTE, replaceList); updateResourceAttributes(attributes, this.resource);