Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [higgins-dev] Problem with removeAttributeValue

Hi Jim,

Although the code you mentioned below does solve the NullPointerException,
it does not actually remove the attribute value.

Refer BasicAttributeSet.java - public void removeAttributeValue(IAttribute
attr) throws IdASException

Here a new BasicAttribute is constructed with values from the attribute
that is passed in to this method.

Refer BasicAttribute.java, here the BasicAttribute constructor calls:

private void _addValue(IAttributeValue val) throws IdASException

which simples copies the value passed in to the values vector in the
attribute being constructed. As a result, the values in the new attribute
being constructed have their container set to the original attribute that
is passed in and not the new attribute itself. Therefore, a
removeAttributeValue does not result in a notification for the right
attribute.

I modified the _addValue code to:
      BasicSimpleValue newval = new BasicSimpleValue(val.getDataType(),
((ISimpleAttrValue)val).getData(), this);
      _values.add(newval);
and it works now.

I hope I have explained the problem clearly. I guess I need to raise
another defect for the same.

Thanks,
Best regards,
Rajalakshmi Iyer




                                                                           
             "Jim Sermersheim"                                             
             <jimse@xxxxxxxxxx                                             
             >                                                          To 
             Sent by:                  <higgins-dev@xxxxxxxxxxx>           
             higgins-dev-bounc                                          cc 
             es@xxxxxxxxxxx                                                
                                                                   Subject 
                                       Re: [higgins-dev] NPE in            
             05/20/2008 12:56          IHasAttributes.removeAttributeValue 
             AM                                                            
                                                                           
                                                                           
             Please respond to                                             
             "Higgins \(Trust                                              
                Framework\)                                                
             Project developer                                             
               discussions"                                                
             <higgins-dev@ecli                                             
                 pse.org>                                                  
                                                                           
                                                                           




Rajalakshmi,

We do need a defect logged for this (if there isn't already one), but there
are also some different code paths you can take to achieve the same results
which will work until this issue is resolved.  Try this:



IEntity person = context.getEntity("uid=riyer,o=JNDITest");
IAttribute tele = context.buildAttribute(URI.create("telephoneNumber"));
tele.addSimpleValue(ITypedValue.STRING_TYPE_URI, "25691129")
person.removeAttributeValue(tele);



You can also use person.getAttribute(URI.create("telephoneNumber")); to get
the telephone attribute and either remove it, or from it, find the
telephone number you want and remove that.



Jim


>>> Rajalakshmi S Iyer <iyer_rajalakshmi@xxxxxxxxxx> 05/19/08 1:08 AM >>>

Hello,

I am trying to remove an attribute's specified value from an Entity using
the JNDI context provider. Here is the code:

IEntity person = context.getEntity("uid=riyer,o=JNDITest");
person.removeAttributeValue(new URI("telephoneNumber"), "25691129");

It is failing with a NullPointerException. The stack trace shows:

java.lang.NullPointerException
      at org.eclipse.higgins.idas.spi.BasicAttribute.<init>(
BasicAttribute.java:105)
      at
org.eclipse.higgins.idas.spi.BasicAttributeSet.removeAttributeValue(
BasicAttributeSet.java:175)
      at org.eclipse.higgins.idas.spi.BasicEntity.removeAttributeValue(
BasicEntity.java:228)
      at org.eclipse.higgins.idas.cp.jndi.JNDIEntity.removeAttributeValue(
JNDIEntity.java:401)
      at
org.eclipse.higgins.idas.cp.jndi.test.JNDICPTest.testRemoveAttributeValueFromPerson(

JNDICPTest.java:108)

The problem lies in the BasicAttribute constructor:

public BasicAttribute(
            URI attrID,
            Object data,
            IAttributeContainer container,
            IContext context) throws IdASException {
            _context = context;
            // Turn the value into an IAttribute
            IAttributeValueModel valueModel = this
.getModel().getValueModel();
                                 .....

Here, the getModel() call is attempted on an uninitialized instance. It
might be needed to modify this API to pass the Object data type as an
argument.

Is this a known problem? If not, should I go ahead and create a bug report
for the same?

Thanks,
Best regards,
Rajalakshmi Iyer

_______________________________________________
higgins-dev mailing list
higgins-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/higgins-dev
_______________________________________________
higgins-dev mailing list
higgins-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/higgins-dev




Back to the top