use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class DCTreeServicesImpl method getDomainAttributes.
protected AttrSet getDomainAttributes(SSOToken token, String orgDN, String[] attrNames) throws AMException, SSOException {
String domainName = null;
try {
AttrSet domAttrSet;
domainName = getCanonicalDomain(token, orgDN);
if (domainName == null) {
debug.error("DCTree.getDomainAttributes-> " + "Domain not found for: " + orgDN);
return null;
}
DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
DomainComponent dcNode = dcTree.getDomainComponent(domainName);
if (attrNames != null) {
domAttrSet = dcNode.getAttributes(attrNames);
} else {
domAttrSet = dcNode.getAttributes(dcNode.getAttributeNames());
}
AttrSet[] attrArray = splitAttrSet(null, domAttrSet);
return attrArray[1];
} catch (UMSException umse) {
debug.error("DCTree.getDomainAttributes: " + " error getting attributes for domain " + domainName);
}
return null;
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class SearchResults method next.
/**
* Returns the next entry in the search results.
*
* @throws UMSException
* No more entries in the search results.
* @supported.api
*/
public PersistentObject next() throws UMSException {
// TODO: define detailed exception list (eg. referral, ...)
//
SearchResultEntry ldapEntry;
if (m_attrVals != null) {
if (m_attrIndex < m_attrVals.length) {
String dn = m_attrVals[m_attrIndex++];
PersistentObject pO = new PersistentObject();
pO.setGuid(new Guid(dn));
pO.setPrincipal(m_principal);
return pO;
} else {
throw new NoSuchElementException();
}
}
if ((ldapEntry = currentEntry) != null) {
String id = ldapEntry.getName().toString();
Collection<Attribute> attributes = new ArrayList<>();
for (Attribute attribute : ldapEntry.getAllAttributes()) {
attributes.add(attribute);
}
AttrSet attrSet = new AttrSet(attributes);
Class javaClass = TemplateManager.getTemplateManager().getJavaClassForEntry(id, attrSet);
PersistentObject pO = null;
try {
pO = (PersistentObject) javaClass.newInstance();
} catch (Exception e) {
String[] args = new String[1];
args[0] = e.toString();
String msg = i18n.getString(IUMSConstants.NEW_INSTANCE_FAILED, args);
throw new UMSException(msg);
}
// Make it a live object
pO.setAttrSet(attrSet);
pO.setGuid(new Guid(ldapEntry.getName().toString()));
pO.setPrincipal(m_principal);
return pO;
}
return null;
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class Resource method getAttributes.
/**
* Return attribute set according to a supplied search template. The search
* template is used as attribute retrieval guidelines.
*
* @param template
* Search template
* @return attribute set with attribute names defined in the template
*
* @supported.api
*/
public AttrSet getAttributes(SearchTemplate template) throws UMSException {
AttrSet attrSet = new AttrSet();
String[] attrNames = template.getAttributeNames();
for (int i = 0; i < attrNames.length; i++) {
attrSet.add(getAttribute(attrNames[i]));
}
return attrSet;
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class TemplateManager method toAttrSet.
private AttrSet toAttrSet(CreationTemplate t) {
AttrSet attrSet = new AttrSet();
attrSet.add(new Attr(TemplateManager.TEMPLATE_NAME, t.getName()));
attrSet.add(new Attr(TemplateManager.TEMPLATE_NAMINGATTRIBUTE, t.getNamingAttribute()));
ArrayList classes = t.getCreationClasses();
String[] classNames = new String[classes.size()];
for (int i = 0; i < classes.size(); i++) {
Class cls = (Class) classes.get(i);
classNames[i] = cls.getName();
}
attrSet.add(new Attr(TemplateManager.TEMPLATE_JAVACLASS, classNames));
Attr required = encodeAttrSet(TemplateManager.TEMPLATE_REQUIRED, t.getRequiredAttributeSet(), "=");
if (required != null) {
attrSet.add(required);
}
Attr optional = encodeAttrSet(TemplateManager.TEMPLATE_OPTIONAL, t.getOptionalAttributeSet(), "=");
if (optional != null) {
attrSet.add(optional);
}
Attr validated = encodeAttrSet(TemplateManager.TEMPLATE_VALIDATED, t.getValidation(), "=");
if (validated != null) {
attrSet.add(validated);
}
return attrSet;
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class PersistentObject method readAttributesFromDataStore.
/**
* Read the attributes from data store
*
* @param attrNames
* names of attributes to get
* @return collection of Attr read from data store
*/
private Collection readAttributesFromDataStore(Collection attrNames) throws UMSException {
Collection attributes = DataLayer.getInstance().getAttributes(getPrincipal(), getGuid(), attrNames);
if (attributes == null) {
String[] args = { getDN() };
throw new UMSException(i18n.getString(IUMSConstants.READ_ATTRIBUTES_ERROR, args));
}
Collection foundAttributes = new ArrayList();
if (m_attrSet == null) {
m_attrSet = new AttrSet();
}
if (m_nullAttributes == null) {
m_nullAttributes = new ArrayList();
}
Iterator iter = attributes.iterator();
while (iter.hasNext()) {
Attr attr = (Attr) iter.next();
foundAttributes.add(attr.getName());
m_attrSet.replace(attr);
}
iter = attrNames.iterator();
while (iter.hasNext()) {
String attrName = (String) iter.next();
if (!foundAttributes.contains(attrName) && !m_nullAttributes.contains(attrName)) {
m_nullAttributes.add(attrName);
}
}
return attributes;
}
Aggregations