use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class UMSObject method getObject.
public static PersistentObject getObject(Principal principal, Guid guid, String[] attrNames) throws UMSException {
AttrSet attrSet = null;
if (attrNames == null) {
attrSet = DataLayer.getInstance().read(principal, guid);
} else {
int length = attrNames.length;
String[] attrNames1 = new String[length + 1];
System.arraycopy(attrNames, 0, attrNames1, 0, length);
attrNames1[length] = "objectclass";
attrSet = DataLayer.getInstance().read(principal, guid, attrNames1);
}
String id = guid.getDn();
if (id == null) {
String msg = i18n.getString(IUMSConstants.BAD_ID);
throw new IllegalArgumentException(msg);
}
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);
}
po.setAttrSet(attrSet);
po.setGuid(guid);
po.setPrincipal(principal);
return po;
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class User 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 SearchTemplate method setAttributeNames.
/**
* Sets the attributes to be returned on a search.
*
* @param attributeNames
* The attribute names to be returned
*
* @supported.api
*/
public void setAttributeNames(String[] attributeNames) {
if (attributeNames != null) {
m_attrSet = new AttrSet();
addAttributeNames(attributeNames);
}
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class PersistentObject method findAttributesNotRead.
/**
* Find the names of attributes not read from data store so far
*
* @param attrNames
* names of attributes to get
* @return collection of names of attributes not read from data store so far
*/
private Collection findAttributesNotRead(String[] attrNames) {
ArrayList attributesNotInCache = new ArrayList();
if (m_attrSet == null) {
m_attrSet = new AttrSet();
}
if (m_nullAttributes == null) {
m_nullAttributes = new ArrayList();
}
int length = attrNames.length;
for (int i = 0; i < length; i++) {
if ((m_attrSet.getAttribute(attrNames[i]) == null) && !m_nullAttributes.contains(attrNames[i])) {
attributesNotInCache.add(attrNames[i]);
}
}
return attributesNotInCache;
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class AMDCTree method splitAttrSet.
protected static AttrSet[] splitAttrSet(String orgDN, AttrSet attrSet) throws AMException {
AttrSet[] attrArray = new AttrSet[2];
attrArray[0] = new AttrSet();
attrArray[1] = new AttrSet();
if (attrSet == null) {
return (attrArray);
}
Set dcNodeAttrs = dcNodeAttributes();
Iterator it = dcNodeAttrs.iterator();
while (it.hasNext()) {
String aName = (String) it.next();
if (aName.indexOf("objectclass=") > -1) {
Attr attr = attrSet.getAttribute("objectclass");
String oc = aName.substring("objectclass=".length());
Attr dcAttr = new Attr("objectclass");
if (attr != null && attr.contains(oc)) {
attr.removeValue(oc);
dcAttr.addValue(oc);
attrSet.replace(attr);
attrArray[1].add(dcAttr);
}
} else {
Attr attr = attrSet.getAttribute(aName);
if (attr != null) {
attrArray[1].add(attr);
attrSet.remove(aName);
}
}
}
attrArray[0] = attrSet;
if (debug.messageEnabled()) {
debug.message("AMCompliance.splitAttrSet: " + "domain attrset = " + attrArray[1].toString());
debug.message("AMCompliance.splitAttrSet: " + "non-domain attrset = " + attrArray[0].toString());
}
return attrArray;
}
Aggregations