Package org.apache.ws.notification.base.v2004_06.callback

Source Code of org.apache.ws.notification.base.v2004_06.callback.UseNotifyResourcePropertyCallback

/*=============================================================================*
*  Copyright 2004 The Apache Software Foundation
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*=============================================================================*/
package org.apache.ws.notification.base.v2004_06.callback;

import org.apache.ws.notification.base.Subscription;
import org.apache.ws.notification.base.v2004_06.porttype.SubscriptionManagerPortType;
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.XmlBoolean;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.UseNotifyDocument;
import javax.xml.namespace.QName;

/**
* A callback for the UseNotify resource property from the WS-BaseNotification
* SubscriptionManager portType.
*
* @author Ian Springer
*/
public class UseNotifyResourcePropertyCallback
   implements SetResourcePropertyCallback
{
   private Subscription m_subscription;

   /**
    * Creates a new {@link UseNotifyResourcePropertyCallback} object.
    *
    * @param subscription DOCUMENT_ME
    */
   public UseNotifyResourcePropertyCallback( Subscription subscription )
   {
      m_subscription = subscription;
   }

   /**
    * DOCUMENT_ME
    *
    * @param propQName DOCUMENT_ME
    *
    * @throws CallbackFailedException DOCUMENT_ME
    * @throws IllegalStateException DOCUMENT_ME
    */
   public void deleteProperty( QName propQName )
   throws CallbackFailedException
   {
      throw new IllegalStateException( "This property cannot be deleted due to schema constraints." );
   }

   /**
    * DOCUMENT_ME
    *
    * @param propElems DOCUMENT_ME
    *
    * @throws CallbackFailedException DOCUMENT_ME
    * @throws IllegalStateException DOCUMENT_ME
    */
   public void insertProperty( Object[] propElems )
   throws CallbackFailedException
   {
      throw new IllegalStateException( "This property cannot be inserted into due to schema constraints." );
   }

   /**
    * DOCUMENT_ME
    *
    * @param prop DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    *
    * @throws CallbackFailedException DOCUMENT_ME
    * @throws IllegalArgumentException DOCUMENT_ME
    */
   public ResourceProperty refreshProperty( ResourceProperty prop )
   throws CallbackFailedException
   {
      QName propName = prop.getMetaData(  ).getName(  );
      if ( !propName.equals( SubscriptionManagerPortType.PROP_QNAME_USE_NOTIFY ) )
      {
         throw new IllegalArgumentException( "Unsupported property: " + propName );
      }

      if ( prop.isEmpty(  ) )
      {
         UseNotifyDocument useNotifyDoc = UseNotifyDocument.Factory.newInstance(  );
         useNotifyDoc.setUseNotify( true );
         prop.add( useNotifyDoc );
      }

      XmlBoolean useNotify = (XmlBoolean) prop.get( 0 );
      useNotify.setBooleanValue( m_subscription.getUseNotify(  ) );
      return prop;
   }

   /**
    * DOCUMENT_ME
    *
    * @param propElems DOCUMENT_ME
    *
    * @throws CallbackFailedException DOCUMENT_ME
    */
   public void updateProperty( Object[] propElems )
   throws CallbackFailedException
   {
      XmlBoolean useNotify = (XmlBoolean) propElems[0];
      m_subscription.setUseNotify( useNotify.getBooleanValue(  ) );
   }
}
TOP

Related Classes of org.apache.ws.notification.base.v2004_06.callback.UseNotifyResourcePropertyCallback

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.