@Override public String toString() { StringBuilder str = new StringBuilder(); return str.append(getClass().getSimpleName()).append(":[id='").append(getId() ).append("', voId='").append(voId ).append("', facilityId='").append(facilityId ).append("', name='").append(name ).append("', description='").append(description).append("']").toString(); }
@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(); }
public void updateResource(Resource resource, ModificationItem[] modificationItems) { ldapTemplate.modifyAttributes(getResourceDN(String.valueOf(resource.getVoId()), String.valueOf(resource.getId())), modificationItems); log.debug("Entry modified in LDAP: Resource {}.", resource); }
@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; }
public static Facility getFacility(RpcCaller rpcCaller, Resource resource) throws InternalErrorException, ResourceNotExistsException, PrivilegeException { Map<String, Object> params = new HashMap<String, Object>(); params.put("resource", resource.getId()); try { return rpcCaller.call("resourcesManager", "getFacility", params).read(Facility.class); } catch (ResourceNotExistsException e) { throw e; } catch (PrivilegeException e) { throw e; } catch (InternalErrorException e) { throw e; } catch (PerunException e) { throw new ConsistencyErrorException(e); } }
public static List<Service> getAssignedServices(RpcCaller rpcCaller, Resource resource) throws InternalErrorException, ResourceNotExistsException, PrivilegeException { Map<String, Object> params = new HashMap<String, Object>(); params.put("resource", resource.getId()); try { return rpcCaller.call("resourcesManager", "getAssignedServices", params).readList(Service.class); } catch (ResourceNotExistsException e) { throw e; } catch (PrivilegeException e) { throw e; } catch (InternalErrorException e) { throw e; } catch (PerunException e) { throw new ConsistencyErrorException(e); } }
public void deleteResource(Resource resource) throws InternalErrorException { try { ldapTemplate.unbind(getResourceDN(String.valueOf(resource.getVoId()), String.valueOf(resource.getId()))); log.debug("Entry deleted from LDAP: Resource {} from Vo with ID=" + resource.getVoId() + " and Facility with ID=" + resource.getFacilityId() + ".", resource); } catch (NameNotFoundException e) { throw new InternalErrorException(e); } }
public boolean resourceAttributeExist(Resource resource, String ldapAttributeName) throws InternalErrorException { if(ldapAttributeName == null) throw new InternalErrorException("ldapAttributeName can't be null."); Object o = null; try { setLdapAttributeName(ldapAttributeName); o = ldapTemplate.lookup(getResourceDN(String.valueOf(resource.getVoId()), String.valueOf(resource.getId())), new AttributeContextMapper()); } catch (NameNotFoundException ex) { return false; } if(o == null) return false; return true; }
@Override public int compareTo(PerunBean perunBean) { if(perunBean == null) throw new NullPointerException("PerunBean to compare with is null."); if(perunBean instanceof Resource) { Resource resource = (Resource) perunBean; if (this.getName() == null && resource.getName() != null) return -1; if (resource.getName() == null && this.getName() != null) return 1; if (this.getName() == null && resource.getName() == null) return 0; return this.getName().compareToIgnoreCase(resource.getName()); } else { return (this.getId() - perunBean.getId()); } } }
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); } }
associatedResources = perun.getResourcesManagerBl().getAssignedResources(perunSession, group); for(Resource r: associatedResources) { writer.write("assignedToResourceId: " + r.getId()); writer.write('\n');
/** * 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()); }
updateGroupAttribute(ldapAttrAssignedToResourceId, String.valueOf(this.resource.getId()), LdapOperation.ADD_ATTRIBUTE, this.group); updateResourceAttribute(ldapAttrAssignedGroupId, String.valueOf(this.group.getId()), LdapOperation.ADD_ATTRIBUTE, this.resource); updateGroupAttribute(ldapAttrAssignedToResourceId, String.valueOf(this.resource.getId()), LdapOperation.REMOVE_ATTRIBUTE, this.group); updateResourceAttribute(ldapAttrAssignedGroupId, String.valueOf(this.group.getId()), LdapOperation.REMOVE_ATTRIBUTE, this.resource);