package example.filesystem.callback;
import example.filesystem.backend.FileSystem;
import org.apache.ws.resource.properties.ResourceProperty;
import org.apache.ws.resource.properties.SetResourcePropertyCallback;
import org.apache.ws.resource.properties.impl.CallbackFailedException;
import org.apache.xmlbeans.XmlString;
import javax.xml.namespace.QName;
/**
* A callback for the Comment resource property.
*/
public class CommentCallback implements SetResourcePropertyCallback
{
FileSystem m_fileSystem;
public CommentCallback( FileSystem fileSystem )
{
m_fileSystem = fileSystem;
}
public void deleteProperty( QName propQName ) throws CallbackFailedException
{
return; // no need to implement - Apollo will never call delete for a prop whose minOccurs != 0
}
public void insertProperty( Object[] propElems ) throws CallbackFailedException
{
// Comment prop has cardinality of 1, so passed array will always have exactly one element
XmlString xString = (XmlString) propElems[0];
m_fileSystem.setComment( xString.getStringValue() );
}
public void updateProperty( Object[] prop ) throws CallbackFailedException
{
insertProperty( prop );
}
public ResourceProperty refreshProperty( ResourceProperty prop ) throws CallbackFailedException
{
XmlString xString = (XmlString) prop.get( 0 );
xString.setStringValue( m_fileSystem.getComment() );
return prop;
}
}